Skip to content

Commit

Permalink
remove exception and fixed is_null to filled
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiHin committed Sep 19, 2024
1 parent 386e7ed commit f90f7ff
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Traits/HasModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ public function setScope(?string $scope): static
{
$this->scope = $scope;

if (!is_null($this->scope) && !method_exists($this->model, 'scope'.ucfirst($this->scope))) {
throw new BadMethodCallException('Scope ' . $this->scope . ' does not exists.');
}

return $this;
}

Expand All @@ -78,7 +74,7 @@ protected function modelQuery(): Builder
->when(filled($relations = $this->getRelationships()), function (Builder $builder) use ($relations) {
$builder->with($relations);
})
->when(!is_null($scope = $this->scope), function (Builder $builder) use ($scope) {
->when(filled($scope = $this->scope), function (Builder $builder) use ($scope) {
$builder->$scope();
});
}
Expand Down

0 comments on commit f90f7ff

Please sign in to comment.