title: Search result with multiple tables relation in Laravel6
body: <p>I'm trying to make search function with relation.
  I could display all result using relation And an another code, simple one table search and get result works fine.
  but I can't combine those two.
  Could you teach me how to combine multiple tables into search function please?</p>
  <pre><code> public function order(Request $request)
  {
      $data = $request-&gt;all();
  
      $products = Product::All();
      $products = Product::with('categori')
          -&gt;join('creators', 'creators.id', '=', 'products.creator_id')
          -&gt;join('categoris', 'categoris.id', '=', 'products.categori_id')
          -&gt;join('branches', 'branches.id', '=', 'products.br_id')
          -&gt;join('users', 'users.id', '=', 'products.user_id')
          -&gt;join('colors', 'colors.id', '=', 'products.color_id')
          -&gt;get();
  
      $products = Product::when($data['categori_id'], function ($query, $categori_id) {
          return $query-&gt;where('categori_id', $categori_id);
      })-&gt;
      when($data['color_id'], function ($query, $color_id) {
          return $query-&gt;where('color_id', $color_id);
      })-&gt;get();
  
   
      //return view('result_fb', compact('images'));
      $data = array(
          'title' =&gt; 'index',
          'no'    =&gt; 1,
          'products'  =&gt; $products,
      );
      return view('product.result', $data);
  }
  </code></pre>