title: Laravel Optional WHERE clause
body: <p>Is there a way to achieve an optional WHERE in Laravel,  this is my query</p>
  
  <pre><code>$people = \App\people::query()
          -&gt; select ('people.name', 'people.username', 'price', 'service','people.city', 'people.streetaddress', 'people.postalcode', DB::raw("GROUP_CONCAT(DATE_FORMAT(datetime, '%H:%i')) as times"))
          -&gt; groupBy('people') 
          -&gt; leftjoin ('services' , 'people.id', '=', 'services.people_id')
          -&gt; leftjoin ('imagesforpeople' , 'people.id', '=', 'imagesforpeople.people_id')
          -&gt; whereDate ('datetime', '=', $request-&gt;get('date'))
          -&gt; whereTime ('datetime', '=', $request-&gt;get('time'))
          -&gt; get();
  </code></pre>
  
  <p>Here, I want this line to be optional</p>
  
  <pre><code>-&gt; whereTime ('datetime', '=', $request-&gt;get('time'))
  </code></pre>
  
  <p>So, if the search does not contain a time, it will completely ignore this line of query. </p>
  
  <p>whereDate is required, but whereTime is not required. If the time request is obtained, it will query for time, but if the time request is not obtained it will ignore the whereTime query, and will show result for whereDate only. </p>
  
  <p>How can I achieve this in Laravel? </p>