<?php

use App\Enums\RolaPouzivatelaEnum;
use App\Models\Informacia\Enums\StavInformacieEnum;
use App\Models\Informacia\Informacia;
use App\Services\HtmlContentGenerator;
use Faker\Generator as Faker;
use Illuminate\Database\Eloquent\Factory;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/

/** @var Factory $factory */
$factory->define(Informacia::class, function (Faker $faker) {
    $stav = $faker->randomElement(StavInformacieEnum::cases());

    return [
        'titulok' => $faker->sentence,
        'uvod' => $faker->paragraph,
        'obsah' => (new HtmlContentGenerator())->generate(rand(10, 20)),
        'stav' => $stav,
        'zverejnit_pre_pouzivatelov_podla_role' => $faker->randomElements(
            RolaPouzivatelaEnum::cases(),
            $faker->numberBetween(0, 5),
        ),
        'planovany_cas_zverejnenia' => ($stav === StavInformacieEnum::PLANOVANE_ZVEREJNENIE(
            )) ? $faker->dateTimeBetween('+1 day', '+5 days') : null,
        'odoslat_email_na_pek' => $faker->boolean,
        'odoslat_email_pouzivatelom' => $faker->boolean,
        'odoslat_push_notifikacie_pouzivatelom' => $faker->boolean,
        'cas_zverejnenia' => ($stav === StavInformacieEnum::ZVEREJNENA()) ? $faker->dateTimeBetween(
            '-50 days',
            '-2 days',
        ) : null,
        'odporucane' => $faker->boolean,
    ];
});
