]> _ Git - cubist_cms-back.git/commitdiff
#2843
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Jun 2019 13:45:21 +0000 (15:45 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Jun 2019 13:45:21 +0000 (15:45 +0200)
src/app/Magic/Models/CMSPage.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/resources/views/fields/button.blade.php

index f93660a59658085038586642b4185073bfd6ad46..c1257ef930df74caaa02dab65a84ef03ffcde5fe 100644 (file)
@@ -156,4 +156,10 @@ class CMSPage extends CubistMagicModel
         }
         $controller->updateFieldsFromModel();
     }
+
+    public function update(array $attributes = [], array $options = [])
+    {
+
+       return parent::update($attributes, $options);
+    }
 }
index 2e679c5ca0ce25d8ae255160b037a8bd2c7e34ed..6b75a2ffaf5d9ae66036405207dc40ab488a43b9 100644 (file)
@@ -12,6 +12,7 @@ use Cubist\Backpack\app\Magic\Util;
 use Backpack\CRUD\ModelTraits\SpatieTranslatable\HasTranslations;
 use Backpack\CRUD\ModelTraits\SpatieTranslatable\Sluggable;
 use Backpack\CRUD\ModelTraits\SpatieTranslatable\SluggableScopeHelpers;
+use Cubist\Util\Json;
 use Doctrine\DBAL\Schema\Schema;
 use Doctrine\DBAL\Schema\Table;
 use Illuminate\Database\Eloquent\Model;
@@ -28,7 +29,10 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         replicate as protected replicateSluggable;
     }
     use SluggableScopeHelpers;
-    use HasTranslations;
+    use HasTranslations {
+        update as protected updateTranslations;
+        create as protected createTranslations;
+    }
     use RevisionableTrait;
     use HasMediaTrait;
     use BunchOfFields {
@@ -475,6 +479,12 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         return Media::where('model_id', $this->getKey())->where('model_type', get_class($this))->get();
     }
 
+    public function update(array $attributes = [], array $options = [])
+    {
+        $attributes = Json::decodeRecursive($attributes, Json::TYPE_ARRAY);
+        return $this->updateTranslations($attributes, $options);
+    }
+
     /**
      * @param $controller CubistMagicController
      */
index 875a713fb79950a2c0e77073492b5aa1f443fed0..694969f9d9ea639bc7ad2e29e4ae001d3abf7c02 100644 (file)
@@ -14,7 +14,7 @@ if ($value == '') {
 if (is_string($value)) {
     $value = json_decode($value, true);
 }
-$value = array_merge($empty, $value);
+$value = array_merge($empty, \Cubist\Util\ArrayUtil::asArray($value));
 
 ?>