php - Get all the values in the table if parameter is null -


products::active($userid) ->where('name','like','%'.input::get('search').'%') ->orderby('created_at', 'desc') ->with('color') ->wherehas('seasons', function ($query)use($seasons) { $query->wherein('season_id', $seasons); }); 

in above query want results if $seasons null. in sql can write where($seasons null) or (season_id in $season). how can write in laravel. wherehas makes inner join. products have atleast 1 season come. how can make left join products come if season null?


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

android - CoordinatorLayout, FAB and container layout conflict -