]> _ Git - cubist_cms-back.git/commitdiff
#2783
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 May 2019 14:31:38 +0000 (16:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 May 2019 14:31:38 +0000 (16:31 +0200)
src/app/Magic/Models/CubistMagicModelAbstract.php

index e1341fc260eb5270c0e3fff58495ce980dc16e3b..fcdd08af09b33ccdaf07d95a6ca78e5c2c6476b3 100644 (file)
@@ -26,15 +26,20 @@ class CubistMagicModelAbstract extends Model
      */
     protected $_options = [];
 
+    private $__attributes;
+
     public function __construct(array $attributes = [])
     {
-        parent::__construct($attributes);
+        $this->__attributes = $attributes;
         $this->init();
     }
 
-    public function init()
+    protected function init()
     {
-
+        $this->bootIfNotBooted();
+        $this->initializeTraits();
+        $this->syncOriginal();
+        $this->fill($this->__attributes);
     }
 
     public function getOption($key, $default = null)
@@ -54,7 +59,16 @@ class CubistMagicModelAbstract extends Model
         $field = Field::getInstance($attributes);
         $name = $field->getAttribute('name');
         $this->_fields[$name] = $field;
-        $this->fillable[] = $name;
+
+        if ($field->getAttribute('fillable')) {
+            $this->fillable[] = $name;
+        }
+        if ($field->getAttribute('guarded')) {
+            $this->guarded[] = $name;
+        }
+        if ($field->getAttribute('hidden')) {
+            $this->hidden[] = $name;
+        }
     }
 
     public function generateCode()