]> _ Git - cubist_cms-back.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 2 Jan 2023 11:05:41 +0000 (12:05 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 2 Jan 2023 11:05:41 +0000 (12:05 +0100)
src/app/Magic/Controllers/CubistMagicController.php
src/app/Magic/Models/CubistMagicAbstractModel.php

index 1834896689a63b000a10e53f4355da343bf31aa9..6f0f12f43d0cbd85667d6f9175ec059ec906e23b 100644 (file)
@@ -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);
         }
     }
 
index 0117ed2a769fe5b5c72ebb9564a4f9a766d7b4da..27b4d121e7744dbed5685c8e9732d03b3e67884c 100644 (file)
@@ -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();
         }