<?php

declare(strict_types=1);

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

use Illuminate\Database\Eloquent\Factories\HasFactory;
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 \Seka\Portal\Modul\Statistiky\Entities\Zaznam\ValueObjects\Subjekt $subjekt
 * @property \Seka\Portal\Modul\Statistiky\Entities\Zaznam\ValueObjects\Udaje   $udaje
 * @property \Carbon\CarbonImmutable                                            $datum
 * @property \Carbon\CarbonImmutable                                            $created_at
 * @property \Carbon\CarbonImmutable                                            $updated_at
 */
class Zaznam extends Model
{
    use HasFactory;

    /**
     * @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,
        'datum' => 'immutable_datetime',
    ];

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