<?php
/**
 * Created by PhpStorm.
 * User: radko
 * Date: 2018-11-27
 * Time: 15:18
 */

namespace Seka\Vzdelavanie\Http\Controllers;

use Exception;
use Illuminate\Routing\Controller;
use Seka\Vzdelavanie\Services\UcebnicaServiceInterface;

/**
 * Class VzdelavanieController
 * @package Seka\Vzdelavanie\Http\Controllers
 */
class VzdelavanieController extends Controller
{
    /**
     * @var \Seka\Vzdelavanie\Services\UcebnicaServiceInterface
     */
    protected $ucebnicaService;

    /**
     * UcebnicaController constructor.
     * @param \Seka\Vzdelavanie\Services\UcebnicaServiceInterface  $ucebnicaService
     */
    public function __construct(UcebnicaServiceInterface $ucebnicaService)
    {
        $this->ucebnicaService = $ucebnicaService;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $kategorie = null;

        try {
            $kategorie = $this->ucebnicaService->vratZoznamUcebnychTextov();
        } catch (Exception $e) {
            flash()->error($e->getMessage())->important();
        } finally {
            return view('Vzdelavanie::pages.vzdelavanie.index', compact('kategorie'));
        }
    }
}
