Laravel factory changed in Laravel 8
In Laravel 8 there are some changes in factory. Let's see that ๐
PostsTableSeeder.php
factory(App\Models\Post::class, 30)->create();
// to ๐
\App\Models\Post::factory()->count(30)->create();
PostFactory.php
protected $model = App\Models\Post::class;
// to ๐
protected $model = \App\Models\Post::class;
------------------------------------------
// and you have to change
'title' => $faker->text(50),
'body' => $faker->text(200)
// to ๐
'title' => $this->faker->text(50),
'body' => $this->faker->text(200)

Md Najmul Hasan
https://shouts.dev/imnhasan
Comments
No comments yetโฆ