-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[12.x] Add shouldRun()
method to Seeder
#57399
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
[12.x] Add shouldRun()
method to Seeder
#57399
Conversation
We need this. @josephkerkhof 👏 |
Everyone knows I hate environment conditional logic, but I must admit, I would greatly benefit from being able to mark which seeders I'd like to run in certain conditions. |
people are still using multiple seeder files? |
You'd be surprised, people are using multiple files now, not just index.php. |
Mind to give an example? |
@taylorotwell I think this has a nicer separation of concerns between "should it run" and "what does it do", but that is certainly debatable. As mentioned originally, I also see it as a nice companion to the function in the Migration abstract class. I think logic regarding inheritance or dynamically setting this with object instances of a Seeder could be mitigated using the if-statement. |
I'd be curious if @rashidlaasri has any further ideas here since he started the discussion thread. |
@josephkerkhof & @taylorotwell The points you mentioned are definitely key, but I'd also like to add "Consistency". One of the great things about Laravel is its API, it’s incredibly intuitive, and almost every method you could imagine already exists. Adding this method feels like a natural extension and helps keep the API consistent across all layers. |
One difference from migrations is that the migration But, there is no such seeder database table and this |
Adds a
shouldRun()
method to the Seeder.php abstract class which gives it a similar ability as theshouldRun()
method in the Migration.php abstract class.Resolves #52708 (comment)
Questions: