Answer the question
In order to leave comments, you need to log in
How to pass whereIn through when in laravel?
...
->when(request('site_id', false), function ($q, $sites) {
$q->whereIn('site_id', $sites); // не работает
})
->when(request('href', false), function ($q, $search) {
$q->where('href', 'like', "%$search%");// работает
}) ...
if($sites) {
$query->whereIn('site_id', $sites); // работает
}
Answer the question
In order to leave comments, you need to log in
Because you need to study PHP first - php.net/manual/en/functions.anonymous.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question