<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Composers\Udalosti;

use Illuminate\Contracts\View\View;
use Seka\Portal\Modul\Terminy\Entities\Udalost\Udalost;

/**
 * Class ZoznamBuducichUdalostiComposer
 *
 * @package Seka\Portal\Modul\Terminy\Composers\Udalosti
 */
final class ZoznamBuducichUdalostiComposer
{
    /**
     * @param \Illuminate\Contracts\View\View $view
     *
     * @return \Illuminate\Contracts\View\View
     */
    public function compose(View $view): View
    {
        $udalosti = Udalost::query()
            ->zverejnena()
            ->where('datum_od', '>', now())
            ->orderBy('datum_od')
            ->limit(5)
            ->get();

        return $view->with(
            'zoznamBuducichUdalosti',
            $udalosti
        );
    }
}
