<?php

declare(strict_types=1);

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

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
use Seka\Portal\Modul\Statistiky\Entities\Import\Enums\StavEnum;
use Seka\Portal\Modul\Statistiky\Entities\Import\Import;
use Seka\Portal\Modul\Statistiky\Entities\Import\ValueObjects\Subor;

/**
 * Class ImportFactory
 *
 * Factory for creating Import model instances.
 *
 * @package Seka\Portal\Modul\Statistiky\Database\Factories
 */
class ImportFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = Import::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     * @throws \Random\RandomException
     */
    public function definition(): array
    {
        $date = Carbon::now()->subDays(rand(0, 30));

        return [
            'subor' => new Subor(
                'NAZOV_SUBORU_' . Carbon::now()->subDays(rand(0, 200))->format('Ymd') . '.csv',
                'subory\pre\import',
                'subory\importovane',
                rand(1000, 5000000)
            ),
            'stav' => $this->faker->randomElement(StavEnum::cases()),
            'datum_cas_akcie' => $date->subMinutes(rand(1, 5)),
            'sprava' => random_bytes(rand(80, 550))
        ];
    }
}
