<?php

namespace App\Http\Controllers\Backend\Informacie;

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

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

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

    /**
     * @return mixed
     *
     * @throws RepositoryException
     */
    public function __invoke()
    {
        $this->informaciaRepository
            ->pushCriteria(OrderDescCriteria::class)
            ->pushCriteria(WithTrashedCriteria::class);
        $informacie = $this->informaciaRepository->paginate();

        return view('pages.sprava.informacie.index')
            ->withInformacie($informacie);
    }
}
