Get all the values in the table if parameter is null
<pre><code>Products::active($userId) -&gt;where('name','like','%'.Input::get('search').'%') -&gt;orderBy('created_at', 'desc') -&gt;with('color') -&gt;whereHas('seasons', function ($query)use($seasons) { $query-&gt;whereIn('season_id', $seasons); });
</code></pre>

<p>In the above query I want to get all the results if <code>$seasons</code> is null. In sql we can write where(<code>$seasons</code> is null) or (<code>season_id</code> in <code>$season</code>). How can I write this in laravel. Also whereHas makes an inner join. So products that have atleast one season will come. How can I make it a left join so that all products will come if season is null?</p>