Skip to content

Comma separated list seems to not work on scopes #857

Answered by dkstudio86
K2ouMais asked this question in Q&A
Discussion options

You must be logged in to vote

Maybe is late... But for references...

public function scopeUserId(Builder $query, string ...$id): Builder
{
    dd($id); // output: array(1, 2, 3)
    return $query->whereIn('id', $id);
}

The '...' make the magic.

Reference:
https://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@K2ouMais
Comment options

Answer selected by K2ouMais
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #856 on April 06, 2023 06:35.