45 lines
1.2 KiB
PHP
45 lines
1.2 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);
|
|
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,
|
|
];
|
|
}
|
|
}
|