dimanche 30 décembre 2018

Laravel Search between two numbers

I currently have the following function in my search controller. I also want to retrieve the results where the space_price is between the user min and max input. I also want the query to work if the user doesn't enter a min or max value or if they enter a max value and no min value it will return the results between 0 and the max value.

$town = $_GET['town'];
$category = $_GET['category'];
$min = $_GET['min'];
$max = $_GET['max'];

$spaces = \App\Space::where([ 
    ['space_town', 'LIKE', '%' . $town . '%'],
    ['space_category', 'LIKE', '%' . $category . '%'],
])->get();

return view('search', compact('spaces'));

Thanks in advance, Jamie



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire