<?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
 */
final class ShowIndexPage extends Controller
{
    private InformaciaRepositoryContract $informaciaRepository;

    /**
     * ShowIndexPage constructor.
     */
    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);
    }
}
