<?php

namespace App\Http\Controllers;

use \Illuminate\Http\Request;

class CalendarController extends Controller
{
    public function show(Request $request, $id)
    {
        parent::registerView($request, 'agenda', $id);
        $apiResult = $this->API('agenda/item/' . (int)$id);
        $calendarEvent = new \Model\CalendarEvent($apiResult);

        return view('calendarevent', ['event' => $calendarEvent, 'metadata' => $calendarEvent->metadata]);
    }

    public function overview(Request $request)
    {
        $apiResult = $this->API('agenda/overzicht');
        $calendar = [];
        foreach($apiResult as $calendarItem)
        {
            $calendar[] = new \Model\CalendarEvent($calendarItem);
        }

        return view('calendarlist', ['events' => $calendar]);
    }
}
