У меня тут при создании factories выводить ошибку (laravel 8) вот код
$factory->define(\App\Models\BlogPost::class, function(Faker $faker)){
$title = $faker->create()->sentence(rand(3,8),true);
$txt = $faker->create()->realText(rand(1000,4000));
$isPublished = rand(1,5) > 1;
$data = [
'category_id' => rand(1,10),
'user_id' => (rand(1,5) == 5) ? 1 : 2,
'title' => $title,
'slug' => Str::of($title)->slug(),
'excerpt' => $faker->create()->text(rand(40,100)),
'content_raw' => $txt,
'content_html' => $txt,
'is_published' => $isPublished,
'published_at' => $isPublished ? $faker->create()->dateTimeBetween('-2 months','-1 days'):null,
'created_at' => $faker->create()->dateTimeBetween('-3 months','-2 months'),
'updated_at' => $faker->create()->dateTimeBetween('-3 months','-2 months'),
];
return $data;
}
ошибка в $factory->define(\App\Models\BlogPost::class, function(Faker $faker))
вот ошибки
1 C:\Users\kosmok\Desktop\OpenServer\domains\laravel\database\factories\BlogPostFactory.php:11
Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Undefined variable: factory", "C:\Users\kosmok\Desktop\OpenServer\domains\laravel\database\factories\BlogPostFactory.php", ["C:\Users\kosmok\Desktop\OpenServer\domains\laravel\vendor\composer/../../database/factories\BlogPostFactory.php"])
2 C:\Users\kosmok\Desktop\OpenServer\domains\laravel\vendor\composer\ClassLoader.php:444
include("C:\Users\kosmok\Desktop\OpenServer\domains\laravel\database\factories\BlogPostFactory.php")