I am trying to use orderBy in my query, but its not working , $price contain 'asc' and 'desc' value after submitting form, but same value is showing in my blade. After click price (high to low) I want to show Product with high to low prices. Thanks Advance
return Listing_property::latest()
->when($city, function ($query, $city) {
return $query->where('city', '=', $city);
})
->when($type, function ($query, $type) {
return $query->where('property_type', '=', $type);
})
->when($purpose, function ($query, $purpose) {
return $query->where('purpose_type', '=', $purpose);
})
->when($bedroom, function ($query, $bedroom) {
return $query->where('bed_room', '=', $bedroom);
})
->when($bathroom, function ($query, $bathroom) {
return $query->where('bathroom', '=', $bathroom);
})
->when($minprice, function ($query, $minprice) {
return $query->where('price', '>=', $minprice);
})
->when($maxprice, function ($query, $maxprice) {
return $query->where('price', '<=', $maxprice);
})
->when($property_size, function ($query, $property_size) {
return $query->where('property_size', '>=', $property_size);
})
->when($property_area_type, function ($query, $property_area_type) {
return $query->where('property_area_type', '<=', $property_area_type);
})
->when($price, function ($query, $price) {
return $query->orderBy('price',$price);
})
->where('add_type', $types)
->paginate(3);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire