<?php

declare(strict_types=1);

namespace App\Livewire\Backend\Pouzivatelia;

use Livewire\Component;

/**
 * Class Pracoviska
 *
 * @package App\Livewire\Backend\Pouzivatelia
 */
final class Pracoviska extends Component
{
    public string $kod = '';

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

        return view('livewire.backend.pouzivatelia.pracoviska', compact('pracoviska'));
    }

    /**
     * @param $value
     */
    public function updatedKod($value): void
    {
        $this->dispatch('filterByPekCode', $value)->to(Zoznam::class);
    }
}
