Gammer
Gammer

Reputation: 5608

Laravel : Records filter

I have a page displaying records from DB regarding products, I want to add filters for them in the right sidebar, My question is, What is the best way to fetch records on "On click".

Currently the filter have the categories, Where a user can click and the related category products will show up. There is also an option for price range, etc

what i can think of right now is :

I am completely blank.

Upvotes: 0

Views: 141

Answers (1)

dparoli
dparoli

Reputation: 9161

IMHO I would go for a GET with querystring parameters using the same index route you have for listing products, i.e.:

GET /products?category=car

This way you dont have to declare different routes.

I have found that using this package https://github.com/Tucker-Eric/EloquentFilter makes coding easier when you have to filter model lists.

Upvotes: 2

Related Questions