56 lines
2.2 KiB
PHP
56 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Approaches\ApproachTypeEnum;
|
|
use App\Models\Approach;
|
|
use App\Models\Meat;
|
|
use App\Models\Range;
|
|
use App\Models\Submeat;
|
|
use App\Models\Subrange;
|
|
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(): array
|
|
{
|
|
$label = fake()->words(3, true);
|
|
$meatBoolean = fake()->boolean(50);
|
|
$rangeBoolean = fake()->boolean(50);
|
|
return [
|
|
'seo_title' => fake()->sentence(),
|
|
'seo_description' => fake()->sentence(),
|
|
'label' => $label,
|
|
'claim_title' => fake()->words(3, true),
|
|
'slug' => Str::slug($label),
|
|
'picture' => '',
|
|
'picture_alt' => fake()->words(5, true),
|
|
'picture_title' => fake()->words(5, true),
|
|
'banner' => '',
|
|
'banner_alt' => fake()->words(5, true),
|
|
'banner_title' => fake()->words(5, true),
|
|
'packaging' => '',
|
|
'packaging_alt' => fake()->words(5, true),
|
|
'packaging_title' => fake()->words(5, true),
|
|
'description' => fake()->sentence(),
|
|
'details' => fake()->sentence(),
|
|
'preparation' => fake()->sentence(),
|
|
'ingredients' => fake()->sentence(),
|
|
'approach_id' => Approach::query()->where('type', ApproachTypeEnum::demarche)
|
|
->inRandomOrder()->value('id'),
|
|
'meat_id' => $meatBoolean ? Meat::query()->inRandomOrder()->value('id') : null,
|
|
'submeat_id' => !$meatBoolean ? Submeat::query()->inRandomOrder()->value('id') : null,
|
|
'range_id' => $rangeBoolean ? Range::query()->inRandomOrder()->value('id') : null,
|
|
'subrange_id' => !$rangeBoolean ? Subrange::query()->inRandomOrder()->value('id') : null,
|
|
'new' => fake()->boolean(50),
|
|
'discover' => fake()->boolean(50),
|
|
'published' => fake()->boolean(75),
|
|
];
|
|
}
|
|
}
|