58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Recipes\DifficultyEnum;
|
|
use App\Models\Range;
|
|
use App\Models\Recipe;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<\App\Models\Recipe>
|
|
*/
|
|
final class RecipeFactory extends Factory
|
|
{
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = Recipe::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$name = fake()->unique()->word;
|
|
|
|
$ingredients = [];
|
|
for ($jj = 1; $jj <= 9; $jj++) {
|
|
array_push($ingredients, [
|
|
"value" => fake()->unique()->words(\rand(2, 8), true)
|
|
]);
|
|
}
|
|
|
|
return [
|
|
'seo_title' => fake()->word,
|
|
'seo_description' => fake()->text(160),
|
|
'name' => $name,
|
|
'slug' => Str::slug($name),
|
|
'picture_alt' => fake()->word,
|
|
'picture_title' => fake()->word,
|
|
'picture_thumbnail_alt' => fake()->word,
|
|
'picture_thumbnail_title' => fake()->word,
|
|
'ingredients' => $ingredients,
|
|
'teaser' => fake()->text(160),
|
|
'steps' => fake()->text,
|
|
'difficulty' => \collect(DifficultyEnum::cases())->random(),
|
|
'duration' => fake()->numberBetween(0, 60),
|
|
'tips' => fake()->text,
|
|
'range_id' => fake()->randomElement(Range::pluck('id')),
|
|
'status' => fake()->boolean(75),
|
|
];
|
|
}
|
|
}
|