Skip to content

Commit 8012da9

Browse files
authored
Update filtering.md to clarify handling of array scope parameter (#976)
Problem discussed here #334
1 parent 9fd030e commit 8012da9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/features/filtering.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ You can even pass multiple parameters to the scope by passing a comma separated
171171
GET /events?filter[schedule.starts_between]=2018-01-01,2018-12-31
172172
```
173173

174+
When passing an array as a parameter you can access it, as an array, in the scope by using the spread operator.
175+
```php
176+
public function scopeInvitedUsers(Builder $query, ...$users): Builder
177+
{
178+
return $query->whereIn('id', $users);
179+
}
180+
```
181+
174182
When using scopes that require model instances in the parameters, we'll automatically try to inject the model instances into your scope. This works the same way as route model binding does for injecting Eloquent models into controllers. For example:
175183

176184
```php

0 commit comments

Comments
 (0)