<?php

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

use Faker\Generator as Faker;
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();

$factory->define(Udalost::class, function (Faker $faker) use ($druhyUdalosti, $stavUdalosti) {
    try {
        return [
            'druh' => $druhyUdalosti[rand(0, count($druhyUdalosti) - 1)],
            'stav' => $stavUdalosti[rand(0, count($stavUdalosti) - 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(),
        ];
    } catch (Exception $e) {

    }
});
