<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Livewire\Components\Filtre;

use Illuminate\View\View;
use Livewire\Component;

/**
 * Class Pracoviska
 *
 * @package Seka\Portal\Modul\Terminy\Livewire\Components\Filtre
 */
final class Pracoviska extends Component
{
    public string $kod = '';

    /**
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function render(): View
    {
        $pracoviska = app()
            ->make('\App\Models\Pracovisko\Pracovisko')
            ->select('id', 'nazov', 'kod')
            ->orderBy('kod')
            ->get();

        return view('Terminy::livewire.components.filtre.pracoviska', compact('pracoviska'));
    }

    public function updatedKod(string $value): void
    {
        $this->dispatch('filterPodlaPracoviska', $value);
    }
}
