<?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
 *
 * @package App\Http\Controllers\Backend\Informacie
 */
class ShowIndexPage 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()
    {
        $this->informaciaRepository
            ->pushCriteria(OrderDescCriteria::class)
            ->pushCriteria(WithTrashedCriteria::class);
        $informacie = $this->informaciaRepository->paginate();

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