Shulei Lee


Seeder can create some fake data in table, it's useful.

  • Create seeder
php artisan make:seeder ArticleSeeder

After that a file named ArticleSeeder.php would be created under database/seeds. Change function run as follow:

public function run()

    for ($i=0; $i < 10; $i++) {
            'title'   => 'Title '.$i,
            'body'    => 'Body '.$i,
            'user_id' => 1,
  • Register seeder

Then we need register ArticleSeeder in project. Modify function run in file database/seeds/DatabaseSeeder.php as follow:

public function run()
  • Excute seed and create fake data

Excuste seed with command php artisan db:seed . You can get the fake data.