<?php

declare(strict_types=1);

namespace Seka\Terminy\Models\Registracia;

use Illuminate\Database\Eloquent\Model;
use Seka\Terminy\Models\Udalost\Udalost;
use Illuminate\Database\Eloquent\SoftDeletes;
use Elceka\Laravel\HashId\Http\Traits\Hashidable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * Class Registracia
 *
 * @package Seka\Terminy\Models\Registracia
 *
 * @property $id
 * @property $udalost_id
 * @property $vytvoril_id
 * @property $pracovisko_id
 * @property $pouzivatel_id
 * @property $meno
 * @property $priezvisko
 * @property $cele_meno
 * @property $poznamka
 * @property $created_at
 * @property $updated_at
 */
final class Registracia extends Model
{
    use Hashidable;
    use SoftDeletes;

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

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

    /**
     * @var string[]
     */
    protected $appends = [
        'cele_meno',
    ];

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

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo|null
     */
    public function pouzivatel(): BelongsTo
    {
        return $this->belongsTo('\App\Models\Pouzivatel\Pouzivatel', 'pouzivatel_id', 'id');
    }

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

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

    /**
     * @return string
     */
    public function getCeleMenoAttribute(): string
    {
        return $this->meno . ' ' . $this->priezvisko;
    }
}
