We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for extensions from Laravel's Eloquent scope extend method: https://www.stephenlewis.me/blog/overriding-eloquent-global-scopes/
extend
<?php namespace App\Scopes; use Illuminate\Database\Eloquent\Scope; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Builder; class AgeScope implements Scope { /** * Restrict results to users aged 18 or over. * * @param Builder $builder * @param Model $model */ public function apply(Builder $builder, Model $model) { $builder->where('age', '>=', 18); } /** * Extend the query builder with the needed functions. * * @param Builder $builder */ public function extend(Builder $builder) { $builder->macro('withYouths', function (Builder $builder) { return $builder->withoutGlobalScope($this); }); } }``` ```php User::withYouths()->get();
Currently it suffices to add the @method static Builder|User withYouths() declaration in your model.
@method static Builder|User withYouths()
The text was updated successfully, but these errors were encountered:
Can you check the hooks if you can write a custom code for it?
Sorry, something went wrong.
No branches or pull requests
Summary
Support for extensions from Laravel's Eloquent scope
extend
method: https://www.stephenlewis.me/blog/overriding-eloquent-global-scopes/Currently it suffices to add the
@method static Builder|User withYouths()
declaration in your model.The text was updated successfully, but these errors were encountered: