I have a products database. I allow users to enter a search term and I display products related to their search term. I'm wanting to add the ability for the user to further filter these results by "gender" using AJAX. If the user selects a gender from a select box this is sent to the URL query string.
here is my code responsible for detecting if "gender" is in the query string.
$searchTerm = request('s');
$gender = request('gender');
$productsQuery = DB::table('products')
->where('title', 'LIKE', "%$searchTerm%");
if ($gender != "") {
$productsQuery->where('gender', '=', "%$gender%");
}
$productsQuery->get();
When this method is called. I receive an empty collection.