<?php

namespace Seka\Portal\Modul\Terminy\Database\Factories;

use DateInterval;
use Faker\Generator as Faker;
use Seka\Portal\Modul\Terminy\Entities\Udalost\StavRegistracie;
use Seka\Portal\Modul\Terminy\Entities\Udalost\StavUpozornenia;
use Seka\Portal\Modul\Terminy\Entities\Udalost\Udalost;
use Seka\Portal\Modul\Terminy\Entities\Udalost\DruhUdalosti;
use Seka\Portal\Modul\Terminy\Entities\Udalost\StavUdalosti;

$druhyUdalosti = DruhUdalosti::toArray();
$stavUdalosti = StavUdalosti::toArray();
$stavRegistracie = StavRegistracie::toArray();
$stavUpozornenia = StavUpozornenia::toArray();

$factory->define(
    Udalost::class,
    function (Faker $faker) use ($druhyUdalosti, $stavUdalosti, $stavRegistracie, $stavUpozornenia) {
        return [
            'druh' => $druhyUdalosti[rand(0, count($druhyUdalosti) - 1)],
            'stav' => $stavUdalosti[rand(0, count($stavUdalosti) - 1)],
            'registracia' => $stavRegistracie[rand(0, count($stavRegistracie) - 1)],
            'upozornenie' => $stavUpozornenia[rand(0, count($stavUpozornenia) - 1)],
            'datum_od' => $od = $faker->dateTime,
            'datum_do' => $od->add(new DateInterval('P' . rand(0, 2) . 'D')),
            'kapacita' => rand(20, 100),
            'povolena_registracia' => (bool) rand(0, 1),
            'miesto_konania' => $faker->city,
            'popis' => $faker->paragraph(),
            'moznosti' => collect([]),
        ];
    }
);
