totalDiaTipoVenta(DashboardController::ESTADO_VENTA); $abono = $this->totalDiaTipoVenta(DashboardController::ESTADO_ABONO); $cancelacion = $this->totalDiaTipoVenta(DashboardController::ESTADO_CANCELACION); return view('dashboard',[ 'venta' => $venta, 'abono' => $abono, 'cancelacion' => $cancelacion ]); } public function totalDiaTipoVenta($tipo_venta) { return Venta::where([ ['estado_venta_id','=', $tipo_venta], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')], ])->sum('pago_efectivo') + Venta::where([ ['estado_venta_id','=', $tipo_venta], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')], ])->sum('pago_tarjeta_debito') + Venta::where([ ['estado_venta_id','=', $tipo_venta], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')], ])->sum('pago_tarjeta_credito') + Venta::where([ ['estado_venta_id','=', $tipo_venta], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')], ])->sum('pago_vales'); } }