From 50e69eacc099df705ecd2e99d62d0f8d4f22951c Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 24 May 2019 16:31:38 +0200 Subject: [PATCH] #2783 --- .../Magic/Models/CubistMagicModelAbstract.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/Magic/Models/CubistMagicModelAbstract.php b/src/app/Magic/Models/CubistMagicModelAbstract.php index e1341fc..fcdd08a 100644 --- a/src/app/Magic/Models/CubistMagicModelAbstract.php +++ b/src/app/Magic/Models/CubistMagicModelAbstract.php @@ -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() -- 2.39.5