Skip to content
Advertisement

Laravel – display data from using data ranges

I want to display data based on ranges within a drop down menu list.I currently have singular values where i would select the value 10 and it would display all values that = 10.

Now i want to have a drop down menu with the options of 5-10, 11-15, 16-20 and i expect it to display all data within those ranges. See code below

Search.php

JavaScript

Search.Controller.php

JavaScript

How would i manage to display the the data using data ranges instead of singular values.

Advertisement

Answer

You can use collection’s groupBy function:

JavaScript

And on your blade:

JavaScript

Note: I haven’t tested it but it gives you the idea.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement