mardi 7 avril 2020

How to display data value according to dropdown in laravel?

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

Here are my ControllerCode..

 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');
    })->get();
  return view('listings-view', compact('products'));
}

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

@foreach($products as $prod)
                        @if($prod->lis_type=='sale')
                        <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">
                                <li>
                                    <i class="fa fa-bed" aria-hidden="true"></i>
                                    <span></span>
                                </li>
                                <li>
                                    <i class="fa fa-bath" aria-hidden="true"></i>
                                    <span> Bathroom</span>
                                </li>
                            </ul>
                        </div>
                        </div>
                        @endif
                        @endforeach


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire