<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Vzdelavanie\Livewire\Components;

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

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

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

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

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