whereBetween in Laravel to include today

Last Updated: August 27, 2020

If you pass the post request with following parameter to your Laravel controller you will not get the value for today
from : ‘2019-01-01′

PurchaseOrder::whereBetween('created_at', [$request->from, $request->to])->sum('total')

So you need to change the code following way

 public function getPurchaseOrderTotal(Request $request){

      return  PurchaseOrder::whereBetween(DB::raw('date(created_at)'), [$request->from, $request->to])->sum('total');