<?php

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

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

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

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

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

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