ldc-wenn-dann-mit-respekt/database/factories/SliderFactory.php
2023-12-12 11:15:57 +00:00

48 lines
1.4 KiB
PHP

<?php
namespace Database\Factories;
use App\Enums\Sliders\TypeEnum;
use App\Models\Slider;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<\App\Models\Slider>
*/
final class SliderFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Slider::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
$linkBoolean = fake()->boolean(75);
$statusBoolean = fake()->boolean(75);
$locales = \collect(\config('app.locales'))->shuffle();
$locales->shift();
return [
'type' => \collect(TypeEnum::cases())->random(),
'title' => fake()->unique()->word,
'subtitle' => fake()->word,
'description' => fake()->text,
'link' => ($linkBoolean) ? fake()->url : null,
'link_title' => ($linkBoolean) ? fake()->word : null,
'link_new_tab' => ($linkBoolean) ? fake()->boolean : false,
'picture_alt' => fake()->word,
'picture_title' => fake()->word,
'status' => $statusBoolean,
'unpublish_at' => null,
'publish_at' => ($statusBoolean) ? fake()->dateTime() : null,
'locales' => $locales
];
}
}