<?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 \App\Repositories\InformaciaRepositoryContract
     */
    private InformaciaRepositoryContract $informaciaRepository;

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

    /**
     * @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);
    }
}
