Skip to content

Commit

Permalink
Fix Laravel 5.1 addVisible does not chain $this
Browse files Browse the repository at this point in the history
  • Loading branch information
kalenjohnson committed Jan 16, 2018
1 parent e70bb0d commit fb3a3a0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Prettus/Repository/Eloquent/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit fb3a3a0

Please sign in to comment.