Laravel Seeder
Seeder can create some fake data in table, it’s useful.
- Create seeder
1 | php artisan make:seeder ArticleSeeder |
After that a file named ArticleSeeder.php would be created under database/seeds. Change function run as follow:
1 | public function run() |
- Register seeder
Then we need register ArticleSeeder in project. Modify function run in file database/seeds/DatabaseSeeder.php as follow:
1 | public function run() |
- Excute seed and create fake data
Excuste seed with command
1 | php artisan db:seed |
. You can get the fake data.