Recent shows go back 2 weeks, next show only shows next week f or now
This commit is contained in:
@@ -203,6 +203,20 @@ QUERY;
|
||||
$program->hosts[] = new \Model\ProgramHost($host);
|
||||
}
|
||||
|
||||
$now = new \DateTimeImmutable('now');
|
||||
$past = $this->createSchedule($now->add(\DateInterval::createFromDateString('-3 weeks')), $now->add(\DateInterval::createFromDateString('+1 week')));
|
||||
$program->recent = [];
|
||||
$program->next = [];
|
||||
foreach($past['schedule'] as $item) {
|
||||
if($item['program']->id == $id) {
|
||||
if(($item['start'] > $now) && !($program->next)) {
|
||||
$program->next = $item['start'];
|
||||
} else if(($item['start'] < $now) && count($program->recent) < 2) {
|
||||
$program->recent[] = $item['start'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($program);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user