1 month ago

How to display data value according to dropdown in laravel?

Posted 1 month ago by sumitgroup

I have a table in my database which has a field lis_type and this (lis_type) field has 2 values sale and rent, and I am calling data on my view page. Suppose I click on Sale page then there should be shown only sale similar listing and if I click on Rent then similar listing should be shown for rent. But right now both listings are coming together, Please let me guide where I am mistaking.

Here is my Controller code...

public function listingshownow(Request $r,$slug)
   $listview= Listing::where('slug',$slug)->first();
    $products = Listing::where('propId',$listview->propId)
   ->where(function ($query) {
    $query->where('lis_type', '=','sale')->orWhere('lis_type','=', 'rent');
   return view('listings-view', compact('products'));

and here are my view file Where I am displaying data... For Similar Listings...

@foreach($products as $prod)
    <div class="row featured portfolio-items">
     <div class="col-lg-7 col-md-12 homes-content pb-0 mb-44">
    <ul class="homes-list clearfix">
     <i class="fa fa-bed" aria-hidden="true"></i>
     <i class="fa fa-bath" aria-hidden="true"></i>
     <span>{{$prod->bathroom}} Bathroom</span>

Please sign in or create an account to participate in this conversation.