57 lines
2.7 KiB
PHP
57 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Approaches\ApproachTypeEnum;
|
|
use App\Models\Approach;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class MainSlideFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
// @phpcs:enable
|
|
$button1status = fake()->boolean(75);
|
|
$button2status = fake()->boolean(75);
|
|
$publishedStatus = fake()->boolean(75);
|
|
$published_at = Carbon::now()->addMonth();
|
|
return [
|
|
'title' => fake()->words(rand(1, 2), true),
|
|
'subtitle' => fake()->words(rand(1, 2), true),
|
|
'approach_id' => (fake()->boolean(50)) ? collect(
|
|
Approach::query()->where('published', true)->where('type', ApproachTypeEnum::demarche)->get()->random(1)
|
|
)->first()->getKey() : null,
|
|
'background' => '',
|
|
'background_alt' => fake()->sentence(),
|
|
'background_title' => fake()->sentence(),
|
|
'picture' => '',
|
|
'picture_alt' => fake()->sentence(),
|
|
'picture_title' => fake()->sentence(),
|
|
'button_1_text' => $button1status ? fake()->sentence(3) : null,
|
|
'button_1_url' => $button1status ? fake()->url() : null,
|
|
'button_2_text' => $button2status ? fake()->sentence(3) : null,
|
|
'button_2_url' => $button2status ? fake()->url() : null,
|
|
'order' => 1,
|
|
'color_block' => fake()->unique()->safeHexColor(),
|
|
'button_1_color_text' => '#FFFFFF',
|
|
'button_1_color_background' => '#4E3238',
|
|
'button_2_color_text' => '#4E3238',
|
|
'button_2_color_background' => '#FFFFFF',
|
|
'button_1_status' => $button1status,
|
|
'button_1_target' => $button1status ? fake()->boolean(75) : false,
|
|
'button_2_status' => $button2status,
|
|
'button_2_target' => $button2status ? fake()->boolean(75) : false,
|
|
'new' => fake()->boolean(75),
|
|
'published' => fake()->boolean(75),
|
|
'published_at' => $publishedStatus ? $published_at : null,
|
|
'unpublished_at' => !$publishedStatus ? $published_at->copy()->addDays(rand(10, 20)) : null,
|
|
];
|
|
}
|
|
}
|