Answer the question
In order to leave comments, you need to log in
Why doesn't whereIn recognize the passed array?
Hello, tell me why when I try to filter by related models and pass an array of values, Undefined variable crashes: request
if ($request->size) {
$productsQuery->whereHas('attributes', function($q) {
$q->whereIn('size', $request->size);
})->get();
}
$productsQuery->whereIn('color', $request->color);
Answer the question
In order to leave comments, you need to log in
$productsQuery->whereHas('attributes', function($q) use ($request) {
$q->whereIn('size', $request->size);
})->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question