@@ -18,7 +18,23 @@ class CalendarEvent extends Model {
|
||||
public $tags;
|
||||
|
||||
public function __construct($data, $images = null, $podcast = null) {
|
||||
// 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 title is a string, not an array
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
|
||||
parent::ConvertToDateTime($this->starts);
|
||||
parent::ConvertToDateTime($this->ends);
|
||||
|
||||
@@ -26,7 +42,7 @@ class CalendarEvent extends Model {
|
||||
if(isset($data->keywords)) {
|
||||
if(is_array($data->keywords)) {
|
||||
$this->keywords = $data->keywords;
|
||||
} else if(trim($data->keywords)) {
|
||||
} else if(trim((string) $data->keywords)) {
|
||||
$this->keywords = explode(' ', $data->keywords);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +63,7 @@ class CalendarEvent extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$this->url = "/agenda/{$this->id}/" . parent::url_slug($this->title);
|
||||
$this->url = "/agenda/{$this->id}/" . parent::url_slug($this->title ?? '');
|
||||
$this->metadata = (new MetaData())
|
||||
->set('title', $this->title)
|
||||
->set('description', strip_tags($this->excerpt()))
|
||||
|
||||
Reference in New Issue
Block a user