A
A
Andrzej Wielski2015-10-28 06:10:30
MySQL
Andrzej Wielski, 2015-10-28 06:10:30

How to implement product filtering in Laravel?

Hello.
I am developing a light online store on Laravel 5.1
I have not come across this framework before (I just started learning).
The database has the following tables:

products
id, name, category_id, brand_id, min_price, max_price

categories
id, slug, name

brands
id, slug, name, logo

products_filters
id, slug, name, dimension

products_filters_values
​​id, filter_id, product_id, value

I implemented the output of products in a category, but I ran into a problem - I have no idea how best to implement product filtering by values ​​(color, size, etc.).
It can be implemented using joins, but I really want to simplify the code using ORM.
I really hope for the help of experts and knowledgeable people.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vyacheslav Plisko, 2015-10-28
@AmdY

There will be something like

Products::has('brands', function($query) {
    $query->where('id', \Input::get('brandId'));
});

A
Andrew, 2015-10-28
@R0dger

If I understood correctly, then you need a faceted search, it is available in Sphinx.
https://github.com/adriannuta/SphinxFacetingExample
Demo - sphinxdemos.adriannuta.com/SphinxFacetingExample

D
Dmitry Evgrafovich, 2015-10-28
@Tantacula

You do not be offended, but in your case it is enough to devote an hour or two to documentation on eloquent'u. If it's too complicated, it's better to give the project to someone who understands what they're doing - you shouldn't spoil the life of your colleagues with shitty code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question