php artisan make:factory CommentFactory
return [
'name' => $this->faker->name,
'text' => $this->faker->text()
];
public function run()
{
Comment::factory()
->times(3)
->create();
}
php artisan db:seed
php artisan tinkerProduct::factory()->count(500)->create()
php artisan make:factory UserFactory
// If you factory is out of standard, you can set an specifc
// On your model, create a static method named newFactory
protected static function newFactory()
{
return DatabaseFactoriesMyModelFactory::new();
}
//On your factory, add this
protected $model = AppModelsMyModel::class;
$users = User::factory()->count(3)->make();
php artisan make:model ModelName -a
// -a stands for all (Model, Controller, Factory and Migration)
// Note: The above command will work successfully in Laravel 5.5 or > versions