jeudi 26 septembre 2019

How to get only the searched data with where clause?


    $data['ads'] = PostAd::where('category_id',$id)      
                          ->orwhere('district_id','LIKE','%'.$location.'%')
                          ->orWhere('condition','LIKE','%'.$condition.'%')
                          ->orWhere('price','>='.$min_price)
                          ->orWhere('price','<='.$max_price)   
                          ->orWhere('fuel',$fuel)
                          ->orWhere('anchalorpradesh',$anchal)
                          ->orWhere('mileage',$mileage)
                          ->orWhere('kilometers',$kilometers)
                          ->orWhere('engine',$engine) 
                          ->get();

i want to show data whose category_id is $id. But whenever i try to search it shows me all the data in the database. Suppose i want to search data whose kilometer is 24. There is only one data whose kilometer is 24. But instead of showing that one data it shows me all the data in database.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ntGQIk
via IFTTT

Aucun commentaire:

Enregistrer un commentaire