<?php

declare(strict_types=1);

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

use DateInterval;
use Illuminate\Database\Eloquent\Factories\Factory;
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;

/**
 * Class UdalostFactory
 *
 * @package Seka\Portal\Modul\Terminy\Database\Factories
 */
class UdalostFactory extends Factory
{
    /**
     * @var string
     */
    protected $model = Udalost::class;

    /**
     * @return array
     * @throws \Exception
     */
    public function definition(): array
    {
        $druhyUdalosti = DruhUdalosti::toArray();
        $stavUdalosti = StavUdalosti::toArray();
        $stavRegistracie = StavRegistracie::toArray();
        $stavUpozornenia = StavUpozornenia::toArray();

        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 = $this->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' => $this->faker->city,
            'popis' => $this->faker->paragraph(),
            'moznosti' => collect([]),
        ];
    }
}