]> _ Git - cubist_cms-back.git/commitdiff
#2868
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 8 Jul 2019 19:47:00 +0000 (21:47 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 8 Jul 2019 19:47:00 +0000 (21:47 +0200)
src/app/Magic/Models/CMSPage.php
src/app/Magic/Models/CubistMagicAbstractModel.php

index e5ed4b95f3fea54b29f1a24fa28df5acf6489f44..6c10f6e1d19d906304033575aa74dcc19525e3f0 100644 (file)
@@ -152,7 +152,11 @@ class CMSPage extends CubistMagicNestedModel
     public static function getTemplatesById()
     {
         if (null === self::$_templatesById) {
-            self::$_templatesById = DB::table(self::$_table)->get()->pluck('template', 'id');
+            try {
+                self::$_templatesById = DB::table(self::$_table)->get()->pluck('template', 'id');
+            } catch (\Exception $e) {
+                self::$_templatesById = [];
+            }
         }
         return self::$_templatesById;
     }
@@ -200,7 +204,11 @@ class CMSPage extends CubistMagicNestedModel
     public static function getPagesList()
     {
         if (null === static::$_pagesList) {
-            static::$_pagesList = DB::table(self::$_table)->orderBy('lft')->get()->pluck('name', 'id');
+            try {
+                static::$_pagesList = DB::table(self::$_table)->orderBy('lft')->get()->pluck('name', 'id');
+            } catch (Exception $e) {
+                static::$_pagesList = [];
+            }
         }
         return static::$_pagesList;
     }
index 9787fbbca17b5fab3f33be8de694d063094b39e4..37ff8d32bd60facb84a3b110d2b48bad422b1e06 100644 (file)
@@ -27,12 +27,12 @@ class CubistMagicAbstractModel extends Model implements HasMedia
     use CrudTrait;
     use Sluggable;
     use SluggableScopeHelpers;
+    use HasMediaTrait;
     use HasTranslations {
         update as protected updateTranslations;
         create as protected createTranslations;
     }
     use RevisionableTrait;
-    use HasMediaTrait;
     use BunchOfFields {
         addField as protected bunchAddField;
     }
@@ -526,4 +526,11 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         return $res;
     }
 
+    public function getMediaInField($c){
+        if(null===$c || !$c){
+            return [];
+        }
+        return $this->getMedia($c);
+    }
+
 }