I want to use some fake data with Factory so at my ArticleFactory
I added this:
public function definition()
{
return [
'title' => $faker->text(50),
'slug' => $faker->slug(),
'body' => $faker->paragraph(rand(5,20)),
];
}
And then at web.php
I added this:
use App\Models\Article;
Route::get('/', function () {
factory(Article::class,10)->create();
});
But now I get this error:
Error Call to undefined function factory()
So what's going wrong here? How can I fix it?