diff --git a/src/Prettus/Repository/Eloquent/BaseRepository.php b/src/Prettus/Repository/Eloquent/BaseRepository.php index ed507905..73eb98cf 100644 --- a/src/Prettus/Repository/Eloquent/BaseRepository.php +++ b/src/Prettus/Repository/Eloquent/BaseRepository.php @@ -558,7 +558,9 @@ public function create(array $attributes) if( version_compare($this->app->version(), "5.2.*", ">") ){ $attributes = $this->model->newInstance()->forceFill($attributes)->makeVisible($this->model->getHidden())->toArray(); }else{ - $attributes = $this->model->newInstance()->forceFill($attributes)->addVisible($this->model->getHidden())->toArray(); + $model = $this->model->newInstance()->forceFill($attributes); + $model->addVisible($this->model->getHidden()); + $attributes = $model->toArray(); } $this->validator->with($attributes)->passesOrFail(ValidatorInterface::RULE_CREATE); @@ -594,7 +596,9 @@ public function update(array $attributes, $id) if( version_compare($this->app->version(), "5.2.*", ">") ){ $attributes = $this->model->newInstance()->forceFill($attributes)->makeVisible($this->model->getHidden())->toArray(); }else{ - $attributes = $this->model->newInstance()->forceFill($attributes)->addVisible($this->model->getHidden())->toArray(); + $model = $this->model->newInstance()->forceFill($attributes); + $model->addVisible($this->model->getHidden()); + $attributes = $model->toArray(); } $this->validator->with($attributes)->setId($id)->passesOrFail(ValidatorInterface::RULE_UPDATE);