title: Filtering search engine data
body: <p>I have a problem with filtering information using a form,</p>
  
  <p>Here is my code</p>
  
  <pre><code>$cooperation = Cooperation::with('user')-&gt;get();
  
  
  
  $search_results = [];
  
  $search = Input::get('q');
  $category = Input::get('c');
  $land = Input::get('l');
  
  if(!empty($search || $category || $land)){
  
  
  
      $search_results = $cooperation;
  
  
  
      if (!empty($search)){
          $search_results = $search_results-&gt;where('title', 'like', '%'. $search .'%');
  
      }
  
      if (!empty($category)){
          $search_results = $search_results-&gt;where('category', $category);
      }
  
      if (!empty($land)){
          $search_results = $search_results-&gt;where('land', $land);
      }
  
      $exist_s = true;
      $not_s = false;
      return view('cooperation.index', compact('cooperation', 'search_results', 'exist_s', 'not_s'));
  
  
  }
  
  else{
  
      $not_s = true;
      $exist_s = false;
      return view('cooperation.index', compact('cooperation', 'search_results', 'exist_s', 'not_s'));
  
  }
  </code></pre>
  
  <p>After retrieving data from the form I am trying to filter through the array in sequence by each variable but nothing happens, the only thing that works is filtering in $ category but I do not know why the rest does not work.</p>
  
  <p>I'm looking for a solution as to how to filter data efficiently, I could do it if () after if () but with more variables it would be a very inefficient solution.</p>
  
  <p>If anyone has any idea in advance thank you.</p>