<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Http\Controllers\Backend\MoznostiUdalosti;

use Illuminate\Contracts\View\View;
use Seka\Portal\Modul\Terminy\Entities\MoznostiUdalosti\MoznostUdalosti;
use Seka\Portal\Modul\Terminy\Entities\MoznostiUdalosti\StavMoznostiUdalostiEnum;
use Seka\Portal\Modul\Terminy\Http\Controllers\Controller;

/**
 * Class MoznostiUdalostiController
 *
 * @package Seka\Portal\Modul\Terminy\Http\Controllers\Backend\MoznostiUdalosti
 */
final class MoznostiUdalostiController extends Controller
{
    /**
     * @return \Illuminate\Contracts\View\View
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function index(): View
    {
        return view('Terminy::pages.moznostiUdalosti.backend.index');
    }

    /**
     * @return \Illuminate\Contracts\View\View
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function create(): View
    {
        $moznostUdalosti = new MoznostUdalosti();
        $moznostUdalosti->stav = StavMoznostiUdalostiEnum::ZVEREJNENA();

        return view('Terminy::pages.moznostiUdalosti.backend.nove')
            ->withMoznostUdalosti($moznostUdalosti);
    }

    /**
     * @param int $id
     *
     * @return \Illuminate\Contracts\View\View
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function edit(int $id): View
    {
        $moznostUdalosti = MoznostUdalosti::withTrashed()->findOrFail($id);

        return view('Terminy::pages.moznostiUdalosti.backend.upravit')
            ->withMoznostUdalosti($moznostUdalosti);
    }
}
