<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Statistiky\Entities\Zaznam;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * Class Zaznam
 *
 * @package Seka\Portal\Modul\Statistiky\Models\Zaznam
 * @property int                                                                $id
 * @property int                                                                $pracovisko_id
 * @property \App\Models\Pracovisko\Pracovisko                                  $pracovisko
 * @property \Carbon\CarbonImmutable                                            $datum
 * @property \Seka\Portal\Modul\Statistiky\Entities\Zaznam\ValueObjects\Subjekt $subjekt
 * @property \Seka\Portal\Modul\Statistiky\Entities\Zaznam\ValueObjects\Udaje   $udaje
 * @property \Carbon\CarbonImmutable                                            $created_at
 * @property \Carbon\CarbonImmutable                                            $updated_at
 */
class Zaznam extends Model
{
    /**
     * @var string
     */
    protected $table = 'modul_statistiky_statisticke_udaje_pracoviska';

    /**
     * @var array
     */
    protected $guarded = [
        'id',
    ];

    /**
     * @var string[]
     */
    protected $casts = [
        'subjekt' => SubjektCastable::class . ':subjekt_druh,subjekt_nazov',
        'udaje' => UdajeCastable::class,
    ];

    /**
     * @var string[]
     */
    protected $dates = [
        'datum',
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function pracovisko(): BelongsTo
    {
        return $this->belongsTo('\App\Models\Pracovisko\Pracovisko', 'pracovisko_id', 'id');
    }
}
