title: How can I used "if" condition in "whereIn" in laravel
body: <p>Below is my query which one i used and working fine for me.</p>
  
  <pre><code>    if($t_requested['category_id'])
      {
          $t_query_condition['p.category_id'] = $t_requested['category_id'];
      }
      if($t_requested['brand_id'])
      {
          $t_query_condition['p.brand_id'] = $t_requested['brand_id'];
      }
  
      $browseData = DB::table('products as p')
          -&gt;leftjoin('categories as cp', 'p.category_id', '=', 'cp.id')
          -&gt;leftjoin('brands as bp', 'p.brand_id', '=', 'bp.id')
          -&gt;select('p.id as product_id','p.name as product_name','cp.title as category_name','bp.name as brand_name','p.product_weight',
                 'p.short_description','p.product_price','p.special_price','p.stock_quantity')
          -&gt;orderBy('p.created_by', "desc")
          -&gt;offset(0)
          -&gt;limit(10)
          -&gt;where($t_query_condition)
          -&gt;get();
  </code></pre>
  
  <p>but Now i have getting multiple id in "category_id" and "brand_id", i want to used <strong>whereIn</strong> but it used with of condition. if i get category_id or brand_id null then it's skip.</p>
  
  <p>thanks in advance.</p>