From: Vincent Vanwaelscappel Date: Mon, 2 Jan 2023 11:05:41 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=99cb771af3d8c3bfe114ace6a46471246e09ff9f;p=cubist_cms-back.git . --- diff --git a/src/app/Magic/Controllers/CubistMagicController.php b/src/app/Magic/Controllers/CubistMagicController.php index 1834896..6f0f12f 100644 --- a/src/app/Magic/Controllers/CubistMagicController.php +++ b/src/app/Magic/Controllers/CubistMagicController.php @@ -153,10 +153,14 @@ class CubistMagicController extends CubistCrudController $model = $this->getModelInstance(); } foreach ($model->getFields() as $field) { - if (isset($this->_fields[$field->getAttribute('name')])) { - continue; + try { + if (isset($this->_fields[$field->getAttribute('name')])) { + continue; + } + $this->addField($field); + }catch (\Error $e){ + dd($field,$e); } - $this->addField($field); } } diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index 0117ed2..27b4d12 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -704,6 +704,9 @@ class CubistMagicAbstractModel extends Model implements HasMedia $res = $this->getMedia($c); if ($res->count() === 0 && $this->hasField($c)) { $c = $this->getAttribute($c); + if(null===$c){ + return []; + } $res = $this->getMedia($c); } return $res; @@ -1100,6 +1103,9 @@ class CubistMagicAbstractModel extends Model implements HasMedia public function getFirstMediaInField(string $fieldName): ?Media { $collection = $this->getMediaInField($fieldName); + if(!$collection){ + return null; + } if ($collection->count() > 0) { return $collection->first(); }