ldc-nature-and-respect/database/factories/RecipeFactory.php
Alexis Gousseau a333993456 add seeders
2023-03-16 09:47:16 +01:00

49 lines
1.3 KiB
PHP

<?php
namespace Database\Factories;
use App\Enums\Recipes\DifficultyEnum;
use App\Enums\Recipes\CookingEnum;
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;
return [
'seo_title' => fake()->word,
'seo_description' => fake()->text,
'name' => $name,
'slug' => Str::slug($name),
'ingredients' => fake()->text,
'teaser' => fake()->text,
'steps' => fake()->text,
'difficulty' => \collect(DifficultyEnum::cases())->random(),
'preparation' => fake()->numberBetween(0, 60),
'duration' => fake()->numberBetween(0, 60),
'astuces' => fake()->text,
'cooking' => \collect(CookingEnum::cases())->random(),
'range_id' => fake()->randomElement(Range::pluck('id')),
'status' => fake()->boolean(75),
];
}
}