Skip to content

Instantly share code, notes, and snippets.

@owenconti
Created May 21, 2020 13:52
Show Gist options
  • Save owenconti/0ab35e9ddef5d338de26e12ec8412fe9 to your computer and use it in GitHub Desktop.
Save owenconti/0ab35e9ddef5d338de26e12ec8412fe9 to your computer and use it in GitHub Desktop.
Calling Laravel seeders from migrations
<?php
// inside migration file
public function up()
{
// Create a table here
// Call seeder
Artisan::call('db:seed', [
'--class' => 'SampleDataSeeder',
]);
}
php artisan migration --force
<?php
// inside migration file
public function up()
{
// Create a table here
// Call seeder
Artisan::call('db:seed', [
'--class' => 'SampleDataSeeder',
'--force' => true // <--- add this line
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment