2024-04-04 13:00:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
2024-04-15 10:34:58 +02:00
|
|
|
use App\Enums\Approaches\ApproachTypeEnum;
|
|
|
|
|
use App\Models\Approach;
|
2024-04-04 13:00:12 +02:00
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
|
|
class MainSlideFactory extends Factory
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Define the model's default state.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, mixed>
|
2024-04-10 13:03:13 +02:00
|
|
|
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
2024-04-04 13:00:12 +02:00
|
|
|
*/
|
|
|
|
|
public function definition()
|
|
|
|
|
{
|
2024-04-10 13:03:13 +02:00
|
|
|
// @phpcs:enable
|
2024-04-04 13:00:12 +02:00
|
|
|
$button1status = fake()->boolean(75);
|
|
|
|
|
$button2status = fake()->boolean(75);
|
|
|
|
|
$publishedStatus = fake()->boolean(75);
|
|
|
|
|
$publish_at = Carbon::now()->addMonth();
|
|
|
|
|
return [
|
|
|
|
|
'title' => fake()->sentence(),
|
|
|
|
|
'subtitle' => fake()->sentence(),
|
2024-04-15 10:34:58 +02:00
|
|
|
'approach_id' => (fake()->boolean(50)) ? collect(
|
|
|
|
|
Approach::query()->where('published', true)->where('type', ApproachTypeEnum::demarche)->get()->random(1)
|
|
|
|
|
)->first()->getKey() : null,
|
2024-04-04 13:00:12 +02:00
|
|
|
'background_alt' => fake()->sentence(),
|
|
|
|
|
'background_title' => fake()->sentence(),
|
|
|
|
|
'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,
|
|
|
|
|
'color_block' => fake()->unique()->safeHexColor(),
|
2024-04-10 13:03:13 +02:00
|
|
|
'button_1_color_text' => '#FFFFFF',
|
|
|
|
|
'button_1_color_background' => '#4E3238',
|
|
|
|
|
'button_2_color_text' => '#4E3238',
|
|
|
|
|
'button_2_color_background' => '#FFFFFF',
|
2024-04-04 13:00:12 +02:00
|
|
|
'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),
|
|
|
|
|
'publish_at' => !$publishedStatus ? $publish_at : null,
|
|
|
|
|
'unpublish_at' => !$publishedStatus ? $publish_at->copy()->addDays(rand(10, 20)) : null,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|