<?php

namespace common\modules\event\models\timetable;

use customerapi\models\available\EventInterval;
use yii\data\ArrayDataProvider;

/** @noinspection PhpUnused */


/**
 * Class TimeTableMonth
 * @property EventInterval $interval
 * @property TimeTableMonthDay[] $days
 * @property TimeTableMonthWeek[] $weeks
 */
class TimeTableMonth
{
    public $interval;
    public $days = array();
    public $weekDayNames = array();
    public $weeks;


    public function getWeeksArrayDataProvider()
    {
        return new ArrayDataProvider([
            'allModels' => $this->weeks
        ]);
    }

    public function getAllEvents(){
        $events = [];
        foreach ($this->days as $day){
            $events = array_merge($events,$day->events);
        }
        return $events;
    }

    public function getWeekByIndex($index) {
        return array_values($this->weeks)[$index];
    }

}
