thinkjay's avatar

Help with Filterable Database Results

Hi, I'm displaying a view from my database that serves as a report. I want the ability for a user to filter the results based on demographic values (ex: State, Year, etc). I want it to update the results live, similar to e-commerce sites like Amazon where you filter by number of stars, or filter by price ranges. You click or select from a dropdown and the results update live (so that user can stay on the same page).

Can someone point me in the right direction, whether it's tutorials here on Laracasts or elsewhere on the web? Thanks!

0 likes
3 replies
ahuggins's avatar

I recently built this for a site. I used jQuery, but Vue would work too. Although if you already have jQuery on your site, and this is the only thing that would use Vue, I would stick with jQuery...but that's just my preference.

I don't know of a tutorial that does exactly this, but basically you just need a route that will return results. You will need to grab the "state" of the form fields you are going to use to query. Then you will need to use AJAX to pass that to the route, which will determine what results based on the parameters you passed and have it return the results. Then have jQuery update the markup.

1 like

Please or to participate in this conversation.