title: Best way to search multiple fields laravel
body: <p>I try to create a function for search using 8 fields. I use this way in the bottom 
  but it's return any offer has one of this given values .
  what I want is the offer he has all values searching .
  The user can searching with any field he want 
  what is the best way to do that whithout a lot of condition if</p>
  
  <pre><code> public function search(Request $request)
          {
              $hashids = new Hashids();
              $city = $request-&gt;city;
              $category = $request-&gt;category;
              $type = $request-&gt;type;
              $rooms = $request-&gt;rooms;
              $minPrice = $request-&gt;minPrice;
              $maxPrice = $request-&gt;maxPrice;
              $minSpace = $request-&gt;minSpace;
              $maxSpace = $request-&gt;maxSpace;
              $citySearch = DB::table('offers')-&gt;where('city',$city);
              $categorySearch = DB::table('offers')-&gt;where('category_id',$category);
              $typeSearch = DB::table('offers')-&gt;where('type',$type);
              $roomsSearch = DB::table('offers')-&gt;where('rooms',$rooms);
              $priceSearch = DB::table('offers')
                  -&gt;whereBetween('price', [$minPrice, $maxPrice]);
              $spaceSearch = DB::table('offers')
                  -&gt;whereBetween('space', [$minSpace, $maxSpace]);
              $result_search = $citySearch-&gt;union($categorySearch)-&gt;union($typeSearch)-&gt;union($roomsSearch)-&gt;union($priceSearch)-&gt;union($spaceSearch)-&gt;get();
              $view = View::make('ajax.search',compact('result_search','hashids'))-&gt;render();
              return response()-&gt;json(['html'=&gt;$view]);
          }
  </code></pre>