<?php

namespace Seka\Terminy\Database\Factories;

use Faker\Generator as Faker;
use Seka\Terminy\Models\Udalost\Udalost;
use Seka\Terminy\Models\Udalost\DruhUdalosti;
use Seka\Terminy\Models\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) {

    }
});
