<?php

declare(strict_types=1);

namespace Seka\Vzdelavanie\Models\Pouzivatel\Testovanie;

use Core\Http\Traits\Hashidable;
use Illuminate\Database\Eloquent\Model;
use Seka\Vzdelavanie\Models\Testovanie\DruhSpravnejOdpovedeEnum;

/**
 * Class Otazka
 *
 * @package Seka\Vzdelavanie\Models\Pouzivatel\Testovanie
 */
class Otazka extends Model
{
    use Hashidable;

    /**
     * @var string
     */
    protected $table = 'vzdelavanie_pouzivatel_testovanie_otazky';

    /**
     * @var string[]
     */
    protected $fillable = [
        'znenie',
        'druh_spravnej_odpovede',
    ];

    /**
     * @var string[]
     */
    protected $casts = [
        'druh_spravnej_odpovede' => DruhSpravnejOdpovedeEnum::class,
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function test()
    {
        return $this->belongsTo(Test::class, 'pouzivatel_testovanie_test_id', 'id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function odpovede()
    {
        return $this->hasMany(Odpoved::class, 'pouzivatel_testovanie_otazka_id', 'id');
    }
}
