public applyScopes ( ) : |
||
return |
public function applyScopes()
{
if (!$this->scopes) {
return $this;
}
$builder = clone $this;
foreach ($this->scopes as $scope) {
$builder->callScope(function (Builder $builder) use($scope) {
if ($scope instanceof Closure) {
$scope($builder);
} elseif ($scope instanceof Scope) {
$scope->apply($builder, $this->getModel());
}
});
}
return $builder;
}
/** * Apply the scopes to the Eloquent builder instance and return it. * * @return \Illuminate\Database\Eloquent\Builder|static * @static */ public static function applyScopes() { return \Illuminate\Database\Eloquent\Builder::applyScopes(); }