For every command you can run --help and see if it does accept any arguments. You can use php artisan db:seed --class=NameOfTheSeederClass to run specific seeder. So the point is just split seeders or reuse logic from one and that is it.
Is it possible to pass arguments to the php artisan migrate command?
For local dev of a Laravel project I'm working on, I often run the following Artisan command to refresh my local DB for testing/dev purposes:
php artisan migrate:fresh --seed
However, there are times when it would be really handy if I could pass one or more additional arbitrary arguments to the migrate command so that I could affect how the seeders function.
For example, I would like to be able to do run a command like the following:
php artisan migrate:fresh --seed --no-extra-users
And hypothetically, the --no-extra-users argument/option would be somehow made available in the database/seeders/DatabaseSeeder.php file so that I could check to see whether it's set or not, and then change up the logic in the DatabaseSeeder file accordingly.
Is this possible? I've been Googling the heck out of this, but have yet to see anything that suggests it's possible. Thank you.
@hartleysan looks like it's not available in the current php artisan migrate:fresh --seed command.
Although what you can do is create one for yourself: https://laravel.com/docs/8.x/artisan#writing-commands
Then you can call commands from your newly created command using this: https://laravel.com/docs/8.x/artisan#calling-commands-from-other-commands
Then you can do whatever you want in the handle() function based on the pass arguments.
Please or to participate in this conversation.