+22
-3
@@ -18,10 +18,29 @@ class Program extends Model {
|
||||
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) {
|
||||
$this->name .= ' ' . $data->suffix;
|
||||
$suffix = $data->suffix;
|
||||
if(is_array($suffix)) {
|
||||
$suffix = $suffix[0] ?? '';
|
||||
}
|
||||
$this->name .= ' ' . $suffix;
|
||||
}
|
||||
|
||||
if($this->recent && $this->recent) {
|
||||
@@ -37,7 +56,7 @@ class Program extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data->email) && ($mailComma = strpos($data->email, ',')) !== false) {
|
||||
if(isset($data->email) && ($mailComma = strpos((string) $data->email, ',')) !== false) {
|
||||
$this->email = substr($data->email, 0, $mailComma);
|
||||
}
|
||||
|
||||
@@ -46,7 +65,7 @@ class Program extends Model {
|
||||
$this->rerun = $data->state == 3;
|
||||
}
|
||||
|
||||
$this->url = "/{$this->id}/" . parent::url_slug($this->name);
|
||||
$this->url = "/{$this->id}/" . parent::url_slug($this->name ?? '');
|
||||
}
|
||||
|
||||
public function isSpecial() {
|
||||
|
||||
Reference in New Issue
Block a user