-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
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
query scopes for models #12
Comments
I think you can create a @method phpdoc in your class for the method active and return static (if using netbeans/phpstorm) or the model itself (or just Eloquent) |
yeah, static works great..
|
Should be detected automatically now.. |
It's only working when the scope is the very first method you use when you are building the query. If you need to use 2 scopes or something like the following (assuming an "active" scope), it's not working. $models = YourModel::query()
->when(
$request->boolean('isActive', false),
function (Builder $query) {
$query->active(); // Warning: Method 'active' not found in \Illuminate\Database\Eloquent\Builder
}
)
->get()
; |
@lsalazarm99
|
@barryvdh Is it possible to have this a a member function on eloquent? MyModel::where('thing', 1)->myScope()->paginate() I suspect it isn't so straightforward as it should only be applicable for a specific model. |
is it possible to have autocompletion query scopes methods while using on model eg.
User::active()->get();
The text was updated successfully, but these errors were encountered: