Is there something I can put in my migrations to automatically seed the table with test data once the migration has completed?
Or do you have to seed separately?
You can call migrate:refresh
with the --seed
option to automatically seed after the migrations are complete:
php artisan migrate:refresh --seed
This will rollback and re-run all your migrations and run all seeders afterwards.
Just as a little extra, you can also always use Artisan::call()
to run an artisan command from inside the application:
Artisan::call('db:seed');
or
Artisan::call('db:seed', array('--class' => 'YourSeederClass'));
if you want specific seeder class.