seeder vs factory laravel
xxxxxxxxxx
Database seeder is used to populate tables with data.
Model factories is a convenient centralized place to define how your models should be populated with fake data.
In seeder class you would leverage model factories, and model factories will most likely use another library to generate random fake data, such as fzaninotto/faker.
xxxxxxxxxx
// factories
// PostFactory.php
'title' => $this->faker->text(20),
// seeders
// PostSeeder.php
Post::factory(20)->create();
// seeders
// DatabaseSeeder.php
$this->call(PostSeeder::class);
>>php artisan migrate::fresh --seed
xxxxxxxxxx
1.make factoryu
php artisan make:factory UserFactory --model=User
2.make seeder
php artisan make:seed UserTableSeeder