<?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\DruhUdalosti;
use Seka\Portal\Modul\Terminy\Entities\Udalost\StavRegistracie;
use Seka\Portal\Modul\Terminy\Entities\Udalost\StavUdalosti;
use Seka\Portal\Modul\Terminy\Entities\Udalost\StavUpozornenia;
use Seka\Portal\Modul\Terminy\Entities\Udalost\Udalost;

/**
 * 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::cases();
        $stavUdalosti = StavUdalosti::cases();
        $stavRegistracie = StavRegistracie::cases();
        $stavUpozornenia = StavUpozornenia::cases();

        return [
            'druh' => $this->faker->randomElement($druhyUdalosti),
            'stav' => $this->faker->randomElement($stavUdalosti),
            'registracia' => $this->faker->randomElement($stavRegistracie),
            'upozornenie' => $this->faker->randomElement($stavUpozornenia),
            '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([]),
        ];
    }
}