<?php

namespace App\Http\Controllers\Backend\Informacie;

use App\Http\Controllers\Controller;
use App\Repositories\Eloquent\Criteria\WithTrashedCriteria;
use App\Repositories\InformaciaRepositoryContract;
use Illuminate\View\View;
use Prettus\Repository\Exceptions\RepositoryException;

/**
 * Class ShowEditPage
 */
class ShowEditPage extends Controller
{
    private InformaciaRepositoryContract $informaciaRepository;

    /**
     * PouzivateliaController constructor.
     */
    public function __construct(InformaciaRepositoryContract $informaciaRepository)
    {
        $this->informaciaRepository = $informaciaRepository;
    }

    /**
     * @throws RepositoryException
     */
    public function __invoke(int $informaciaId): View
    {
        $informacia = $this->informaciaRepository
            ->pushCriteria(WithTrashedCriteria::class)
            ->with('vytvoril')
            ->find(
                $informaciaId,
            );

        return view('pages.backend.informacie.edit')->withInformacia($informacia);
    }
}
