Files
nhgooi.nl/app/Models/Program.php
T
root 30893eb7a7
Build and Deploy / build (push) Failing after 44s
Changes by CLaude
2026-08-18 09:31:05 -01:00

75 lines
1.7 KiB
PHP
Executable File

<?php
namespace Model;
class Program extends Model {
public $id;
public $name;
public $tagline;
public $description;
public $email;
public $nonstop;
public $rerun;
public $priority;
public $image;
public $hosts;
public $recent;
public $next;
public function __construct($data) {
// Convert arrays to objects for consistent handling
if(is_array($data)) {
$data = (object) $data;
}
parent::__construct($data);
// Ensure id is a string, not an array
if(is_array($this->id)) {
$this->id = $this->id[0] ?? '';
}
// Ensure name is a string, not an array
if(is_array($this->name)) {
$this->name = $this->name[0] ?? '';
}
if(isset($data->suffix) && $data->suffix) {
$suffix = $data->suffix;
if(is_array($suffix)) {
$suffix = $suffix[0] ?? '';
}
$this->name .= ' ' . $suffix;
}
if($this->recent && $this->recent) {
foreach($this->recent as &$recent) {
parent::ConvertToDateTime($recent->starts);
parent::ConvertToDateTime($recent->ends);
}
}
if($this->next && $this->next) {
foreach($this->next as &$next) {
parent::ConvertToDateTime($next->starts);
parent::ConvertToDateTime($next->ends);
}
}
if(isset($data->email) && ($mailComma = strpos((string) $data->email, ',')) !== false) {
$this->email = substr($data->email, 0, $mailComma);
}
if(isset($data->state)) {
$this->nonstop = $data->state == 0;
$this->rerun = $data->state == 3;
}
$this->url = "/{$this->id}/" . parent::url_slug($this->name ?? '');
}
public function isSpecial() {
return ($this->priority < 2);
}
}