From: Vincent Vanwaelscappel Date: Fri, 24 May 2019 14:31:38 +0000 (+0200) Subject: #2783 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=50e69eacc099df705ecd2e99d62d0f8d4f22951c;p=cubist_cms-back.git #2783 --- 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()