Replies: 2 comments 2 replies
-
# controller
$userQuery = QueryBuilder::for(User::query())
->allowedFilters([AllowedFilter::scope('year')]);
# model
public function scopeYear(Builder $query, $year): Builder
{
return $query
->where('year', '>=', $year)
->where('year', '<=', $year);
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
You can use different separator then in model public function scopeYear($query, $year)
{
$dates = explode(":", $year);
return $query->whereBetween('year', $dates);
}
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to filter between two values.
$data = Car::where('year', '>=', $input['year_from'])->where('year', '<=', $input['year_to'] )->get();
Beta Was this translation helpful? Give feedback.
All reactions