<?php

namespace App\Http\Controllers\Backend\Informacie\Hodnotenia;

use App\Http\Controllers\Controller;
use App\Repositories\Eloquent\Criteria\WithTrashedCriteria;
use App\Repositories\InformaciaRepositoryContract;

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

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

    /**
     * @param null $informaciaId
     *
     * @return void
     * @throws \Prettus\Repository\Exceptions\RepositoryException
     */
    public function __invoke($informaciaId = null)
    {
        $informacia = $this->informaciaRepository
            ->pushCriteria(WithTrashedCriteria::class)
            ->find(
                $informaciaId,
            );

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