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);
|
$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);
|
return response()->json($program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ class Program extends Model {
|
|||||||
public $priority;
|
public $priority;
|
||||||
|
|
||||||
public $hosts;
|
public $hosts;
|
||||||
public $schedule;
|
public $recent;
|
||||||
|
public $next;
|
||||||
|
|
||||||
public function __construct($data) {
|
public function __construct($data) {
|
||||||
parent::__construct($data);
|
parent::__construct($data);
|
||||||
@@ -19,13 +20,10 @@ class Program extends Model {
|
|||||||
$this->name .= ' ' . $data->suffix;
|
$this->name .= ' ' . $data->suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->schedule && $this->schedule->next && $this->schedule->next->time) {
|
parent::ConvertToDateTime($this->next);
|
||||||
parent::ConvertToDateTime($this->schedule->next->time);
|
if($this->recent && $this->recent) {
|
||||||
}
|
foreach($this->recent as &$recent) {
|
||||||
|
parent::ConvertToDateTime($recent);
|
||||||
if($this->schedule && $this->schedule->recent) {
|
|
||||||
foreach($this->schedule->recent as &$recent) {
|
|
||||||
parent::ConvertToDateTime($recent->time);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user