Open faiverson opened 4 years ago
I add that it is not only a problem with @inject, you cannot set any directives to modify $args and then use them in the scope, because the scope is using the args from argumentSet and argumentSet never changes (that's why @inject is not working either)
We might try to construct the ArgumentSet
later, when the $args
have been modified. That would require dealing with untyped and dynamic args, though.
You should use Auth::user() in scope
public function scopeOwner(Builder $query, array $args)
{
return $query->where('id', Auth::user()->id);
}
f I want to make a pagination (eg. user blog entries) and make sure that the user is the logged user in the system, I’d like to use @inject
Then I imagine to use scopes in order to filter the blog entries for that user The problem is that id never goes to scope as an argument (I think it should) because the arguments are set here:
argumentSet is not considering the @inject directive that’s why id is not appending to args, when you call:
Lighthouse Version: latest Laravel Version: latest