Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artisan commands for registering existing models as reactants/reacters #127

Merged

Conversation

sburkett
Copy link
Contributor

@sburkett sburkett commented Nov 5, 2019

Fairly straightforward. These two artisan commands can be invoked to register any or all existing model rows for reactants or reacters. Both commands accept the same parameters, as outlined below.

Command Help

Here is the output of artisan help for the love:register-reactant command (the reacter command follows a similar pattern):

image

Use Cases

Process all records for the passed model:

php artisan love:register-reactables App\\Models\\Entry
php artisan love:register-reacters App\\Models\\User

Process specific records for the passed model:

php artisan love:register-reactables App\\Models\\Entry --ids=1,2,3,4,19
php artisan love:register-reacters App\\Models\\User --ids=200,312,319

Sample output (yes, I love progress bars lol):

image

Feel free to merge and make any changes or tweaks that you feel necessary.

@sburkett
Copy link
Contributor Author

sburkett commented Nov 5, 2019

Seems like style-ci is not configured properly?

@antonkomarev
Copy link
Member

I think CI issue happens because Laravel changed code style recently.

@antonkomarev
Copy link
Member

I've fixed StyleCI in #128
With next commit it should work correctly.

src/Console/Commands/RegisterExistingReactables.php Outdated Show resolved Hide resolved
src/Console/Commands/RegisterExistingReactables.php Outdated Show resolved Hide resolved
src/Console/Commands/RegisterExistingReactables.php Outdated Show resolved Hide resolved
src/Console/Commands/RegisterExistingReactables.php Outdated Show resolved Hide resolved
src/Console/Commands/RegisterExistingReactables.php Outdated Show resolved Hide resolved
@antonkomarev
Copy link
Member

I've reviewed only one class quickly. With following fixes StyleCI will add more issues in this list.

@antonkomarev
Copy link
Member

antonkomarev commented Nov 5, 2019

There should be an ability to resolve model class name from the morph map:

php artisan love:register-reacters user

You can see how it's implemented in Recount command.

@sburkett
Copy link
Contributor Author

sburkett commented Nov 5, 2019

Sorry, personal coding style habits in action there :) I'll address when I have the time.

@antonkomarev
Copy link
Member

Just noticed command naming issue. reactables should be renamed to reactants.

@sburkett
Copy link
Contributor Author

sburkett commented Nov 7, 2019

Ok, cool. I will adjust that as well. I am out of the office until tomorrow, but will get back on it soon.

@antonkomarev
Copy link
Member

@sburkett I've refactored your implementation. Tried to make it clean and as simple as possible.

@antonkomarev antonkomarev changed the title Artisan commands for registering existing reactables/reacters Artisan commands for registering existing reactants/reacters Jan 26, 2020
@antonkomarev
Copy link
Member

Final API

Register models as Reactants

Using fully qualified class name

$ php artisan love:register-reactants --model="App\Article"

Using morph map

$ php artisan love:register-reactants --model=article

Specify ids delimited with comma

$ php artisan love:register-reactants --model="App\Article" --ids=1,4,25

Specify ids using option array

$ php artisan love:register-reactants --model="App\Article" --ids=1 --ids=4 --ids=25

Register models as Reacters

Using fully qualified class name

$ php artisan love:register-reacters --model="App\User"

Using morph map

$ php artisan love:register-reacters --model=user

Specify ids delimited with comma

$ php artisan love:register-reacters --model="App\User" --ids=1,4,25

Specify ids using option array

$ php artisan love:register-reacters --model="App\User" --ids=1 --ids=4 --ids=25

@antonkomarev antonkomarev changed the title Artisan commands for registering existing reactants/reacters Artisan commands for registering existing models as reactants/reacters Jan 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants