Created
May 21, 2020 13:52
-
-
Save owenconti/0ab35e9ddef5d338de26e12ec8412fe9 to your computer and use it in GitHub Desktop.
Calling Laravel seeders from migrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// inside migration file | |
public function up() | |
{ | |
// Create a table here | |
// Call seeder | |
Artisan::call('db:seed', [ | |
'--class' => 'SampleDataSeeder', | |
]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php artisan migration --force |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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