ldc-agis/database/factories/ProductFactory.php
2023-10-20 07:39:18 +00:00

50 lines
2 KiB
PHP

<?php
namespace Database\Factories;
use App\Enums\Products\CookingModeEnum;
use App\Models\Range;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class ProductFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
$title = fake()->sentence();
return [
'seo_title' => fake()->word(),
'seo_description' => fake()->text(160),
'title' => $title,
'slug' => Str::slug($title),
'subtitle' => fake()->sentence(),
'picture_thumbnail_alt' => fake()->sentence(),
'picture_thumbnail_title' => fake()->sentence(),
'picture_ambiance_alt' => fake()->sentence(),
'picture_ambiance_title' => fake()->sentence(),
'picture_packshot_alt' => fake()->sentence(),
'picture_packshot_title' => fake()->sentence(),
'description' => \clean(\fake()->randomHtml(6, 7)),
'cooking_mode' => \collect(CookingModeEnum::cases())->random(),
'cooking_advice' => \clean(\fake()->randomHtml(6, 7)),
'ingredients' => \clean(\fake()->randomHtml(6, 7)),
'nutritionnal_values' => json_encode([
'Energie en Kj' => fake()->randomFloat(2),
'Energie en kcal' => fake()->randomFloat(2),
'Matières grasses' => fake()->randomFloat(2),
'dont acides gras saturés' => fake()->randomFloat(2),
'Glucides' => fake()->randomFloat(2),
'Protéines' => fake()->randomFloat(2),
'Sel' => fake()->randomFloat(2),
]),
'published' => fake()->boolean(75),
'range_id' => Range::all()->random()->id,
];
}
}