Skip to content

Too few arguments to function App\Models\User::scopeRole(), 1 passed in /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php #2477

Closed Answered by drbyte
loxK asked this question in Q&A
Discussion options

You must be logged in to vote

It seems maybe your query is firing the scope when you were trying to write a bespoke lookup of your own, and they're working against each other.

Did you mean something like this?

$users_query = User::query();

if (null !== $request->certified) {
    if ($request->certified) {
        $users_query = $users_query->role('professional_certified');
    } else {
        $users_query = $users_query->withoutRole('professional_certified');
    }
}

// note: withoutRole() scope requires v6.x
// but you could copy the withoutRole scope from the v6 trait into your User model as a temporary bridge until v6 is released

If that's not what you meant, do you mind writing out in english what you "meant" t…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by loxK
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants