title: Laravel controller query
body: <p>I have a laravel project with Laravel Framework 5.8.38
  I try to convert mysql query:</p>
  <pre><code>SELECT b.name as business_location_name , u.first_name as cashier_first_name , u.last_name as cashier_last_name , cr.location_id , SUM(CASE WHEN tp.is_return = '0' AND tp.method = 'cash' THEN tp.amount ELSE 0 END) totalCash, SUM(CASE WHEN tp.is_return = '1' AND tp.method = 'cash' THEN tp.amount ELSE 0 END) totalReturn , SUM(CASE WHEN tp.is_return = '0' AND tp.method = 'card' THEN tp.amount ELSE 0 END) totalCard , cr.created_at , cr.closed_at
  FROM cash_registers as cr
  LEFT JOIN transaction_payments as tp ON cr.user_id = tp.created_by
  LEFT JOIN users as u ON u.id = cr.user_id
  LEFT JOIN business_locations as b ON b.id = cr.location_id
  WHERE (tp.paid_on BETWEEN cr.created_at AND cr.closed_at) AND cr.status = &quot;close&quot; AND cr.created_at LIKE &quot;2022-06-01%&quot;
  GROUP BY cr.location_id , cr.user_id
  ORDER BY cr.location_id ASC, cr.user_id ASC
  </code></pre>
  <p>To lavravel query</p>
  <pre><code>$startDate = &quot;2022-06-01&quot;;
     $results3 = DB::table('cash_registers as cr')
             -&gt;select(DB::raw('b.name as business_location_name , u.first_name as cashier_first_name , u.last_name as cashier_last_name , cr.location_id , SUM(CASE WHEN tp.is_return = &quot;0&quot; AND tp.method = &quot;cash&quot; THEN tp.amount ELSE 0 END) totalCash, SUM(CASE WHEN tp.is_return = &quot;1&quot; AND tp.method = &quot;cash&quot; THEN tp.amount ELSE 0 END) totalReturn , SUM(CASE WHEN tp.is_return = &quot;0&quot; AND tp.method = &quot;card&quot; THEN tp.amount ELSE 0 END) totalCard , cr.created_at , cr.closed_at'))
             -&gt;leftjoin('transaction_payments as tp','tp.created_by', '=', 'cr.user_id')
             -&gt;leftjoin('users as u','u.id', '=', 'cr.user_id')
             -&gt;leftjoin('business_locations as b','b.id', '=', 'cr.location_id')
             -&gt;whereBetween('tp.paid_on',['cr.created_at', 'cr.closed_at'])
             -&gt;where('cr.status', '=' , 'close')
             -&gt;where(&quot;cr.created_at&quot;, &quot;like&quot;, $startDate.'%')
             -&gt;groupBy('cr.location_id')
             -&gt;groupBy('cr.user_id')
             -&gt;orderBy('cr.location_id', 'asc')
             -&gt;orderBy('cr.user_id', 'asc')
             -&gt;get();
  </code></pre>
  <p>But when I run the query on phpmyadmin ,it returns correct result , but when fire the laravel query , it returns empty array []</p>
  <p>What's the problem ?</p>
  <p>Thanks in advance</p>