I'm trying to make my first factory for my model Car. Each time I try to run it I get Argument #1 ($values) must be of type array, string given. CarFactory.php:71.
I do have hasMany relationship. Category and Cars are connected like this:
public function cars()
{
return $this->hasMany(Car::class);
}
I think my Factory is failing when I try to connect a car to a category. This is my factory:
return [
'slug' => Str::of($carSlug)->slug('-'),
'manufacturer' => $carMani,
'model' => $carModel,
'range' => $this->faker->numberBetween(120, 650),
'drive' => $this->faker->shuffleArray(['AWD', 'RWD', 'FWD']),
'seating' => $this->faker->numberBetween(3, 5),
'luggage' => $this->faker->numberBetween(1, 6),
'description' => $this->faker->text,
'category_id' => Category::factory()->count(1)->create()->id,
'image_folder_url' => $this->faker->url,
'price_per_day' => $this->faker->randomNumber(5),
];
And this is the seeder:
Car::factory()->has(Category::factory()->count(1))->count(50)->create();