@@ -9,8 +9,18 @@ class NewsImage extends Model {
|
||||
public $url;
|
||||
|
||||
public function __construct($data, $urlPrefix = '/') {
|
||||
// Convert arrays to objects for consistent handling
|
||||
if(is_array($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
parent::__construct($data);
|
||||
|
||||
// Ensure title is a string, not an array
|
||||
if(is_array($this->title)) {
|
||||
$this->title = $this->title[0] ?? '';
|
||||
}
|
||||
|
||||
// Deserialisatie van JSON heeft url in data,
|
||||
// lezen uit database heeft file en (als het goed is) urlPrefix
|
||||
if(isset($data->file)) {
|
||||
|
||||
Reference in New Issue
Block a user