<?php

namespace App\Http\Controllers\Backend\Informacie;

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

/**
 * Class ShowEditPage
 *
 * @package App\Http\Controllers\Backend\Informacie
 */
class ShowEditPage extends Controller
{
    /**
     * @var InformaciaRepositoryContract
     */
    private InformaciaRepositoryContract $informaciaRepository;

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

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

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