title: Call to a member function whereBetween() on integer in laravel 5.4?
body: <p>I am trying to use whereBetween between 2 different dates but I am getting an error "Call to a member function whereBetween() on integer". I am using bootstrap datepicker for getting 2 date inputs from the user. My code is below:</p>
  
  <p>My form is below:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
   &lt;label for="start_date"&gt;From:&lt;/label&gt;&lt;input type="text" name="startdate" id="startdate"&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
   &lt;label for="enddate"&gt;To:&lt;/label&gt;&lt;input type="text" id="enddate" name="enddate"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My query is below:</p>
  
  <pre><code>$client_ids = Array
                (
                   [0] =&gt; 1
                   [1] =&gt; 5
                 )
  $start = 2017-06-01;
  $end = 2017-06-02;
  
  $results = DB::table('lead_audit AS l')
               -&gt;leftjoin('suppliers AS s', 's.id', '=', 'l.supplier_id')
               -&gt;leftjoin('campaigns AS c', 'c.id', '=', 'l.campaign_id')
               -&gt;select('s.name AS Supplier', 'c.name AS Campaign', 'l.disposition AS Disposition')
               -&gt;count()
               -&gt;whereBetween('l.received', [$start, $end])
               -&gt;whereIn('l.client_id', $client_ids)
               -&gt;groupBy('s.name', 'c.name', 'l.disposition')
               -&gt;orderBy('s.name')
               -&gt;orderBy('c.name')
               -&gt;orderBy('l.disposition')
               -&gt;get();
  </code></pre>
  
  <p>I googled it and I have tried a solution of "Wrap the dates in Carbon objects" like below
  On top of my controller I have put this line "use Carbon\Carbon;" and changed the query at whereBetween is present like below:</p>
  
  <pre><code>-&gt;whereBetween('l.received', [new Carbon($start), new Carbon($end)])
  </code></pre>
  
  <p>But no luck again the same error as "Call to a member function whereBetween() on integer". I also have a doubt that is the above full query's order is correct or not? Can someone please help me what's wrong in this. Thanks.</p>