/** * It returns a chuck of HTML * @param $exhibitionId * @return \Symfony\Component\HttpFoundation\Response|static */ public function search($exhibitionId) { if (Input::has('since')) { try { $since = Carbon::createFromFormat(MYSQL_DATE_FORMAT, Input::get('since'))->startOfDay(); } catch (InvalidArgumentException $e) { return ''; } } else { $since = null; } if (Input::has('until')) { try { $until = Carbon::createFromFormat(MYSQL_DATE_FORMAT, Input::get('until')); } catch (InvalidArgumentException $e) { return ''; } } else { $until = null; } $schedules = $this->schedulesRepository->findByExhibitionAndDateInterval($exhibitionId, $since, $until); if ($schedules->isEmpty()) { return View::make('exhibitions.frontend.exhibitions.partials.none-extra-schedule'); } return View::make('exhibitions.frontend.exhibitions.partials.more-schedules', compact('schedules')); }
/** * @param string $from * @param string $until * @return \Illuminate\Support\Collection */ public function findByDateInterval($from, $until = null) { if ($until === null) { $today = Carbon::today(); $until = Carbon::createFromDate($today->year, $today->month, $today->daysInMonth)->toDateString(); } $schedulesByAuditorium = $this->repository->findByDateIntervalGroupByAuditorium($from, $until); $activities = $this->createActivities($schedulesByAuditorium); return $activities; }
/** * @param Carbon $date The date is cloned internally so it is avoided side-effects * @return array */ public function getCalendar(Carbon $date) { $date = clone $date; $calendar = $this->calendarGenerator->generate($date); $schedules = $this->schedulesRepository->findOfMonth($date)->groupBy(function (Type\Schedule $schedule) { return $schedule->getEntry()->day; })->all(); /** @var \Filmoteca\Exhibition\Type\Calendar\Day $day */ foreach ($calendar->getDays() as $day) { $dayNumber = $day->getNumber(); if (array_key_exists($dayNumber, $schedules)) { $day->setExhibitionsNumber(count($schedules[$dayNumber])); } } return $calendar; }