#development #laravel #pattern #php
When you use seeders to populate your database in Laravel, you sometimes have the need to run these from your code (e.g. from a command-line utility of after a certain migration happened.
It turns out this is very easy to do:
1$seeder = new UserSeeder(); 2$seeder->run();
If you want to run them from the command-line, you do:
php artisan db:seed --class=UserSeeder
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.