Answer the question
In order to leave comments, you need to log in
How to make a dynamic product filter in Laravel?
There are related tables Goods and Sizes, Brands, Parameters.
The filtering process itself is implemented, i.e. product selection:
Controller:
$goods = Good::select('id', 'name', 'brand_id', 'price');
$goods = (new MyGoodsFilter($goods, $request))->apply();
$goods = $goods->get();
// Фильтрация по размерам
$this->builder->whereHas('sizeid', function ($query) use ($value) {
$query->Where(function ($query) use ($value) {
$sizes = explode(",", $value);
foreach ($sizes as $size) {
$query->orwhere('size_id', '=', $size);
}
});
Answer the question
In order to leave comments, you need to log in
Display to the user a list of parameters that are in the table of the corresponding products.
Make a request based on $request (we filter which parameters came from them)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question