format('Y-m-d')] // ])->count()); $movimiento = $this->totalDiaTipoMovimiento(DashboardController::ESTADO_VENTA); $abono = $this->totalDiaTipoMovimiento(DashboardController::ESTADO_ABONO); $cancelacion = $this->totalDiaTipoMovimiento(DashboardController::ESTADO_CANCELACION); $this->validarCaja(); return view('dashboard',[ 'movimiento' => $movimiento, 'abono' => $abono, 'cancelacion' => $cancelacion, 'num_movimiento' => Movimiento::where([ ['estado_movimiento_id','=', DashboardController::ESTADO_VENTA], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')] ])->count(), 'num_abono' => Movimiento::where([ ['estado_movimiento_id','=', DashboardController::ESTADO_ABONO], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')] ])->count(), 'num_cancelacion' => Movimiento::where([ ['estado_movimiento_id','=', DashboardController::ESTADO_CANCELACION], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')] ])->count(), 'caja' => CajaMovimiento::cajaInicial(), ]); } public function totalDiaTipoMovimiento($tipo_movimiento) { return Movimiento::where([ ['estado_movimiento_id','=', $tipo_movimiento], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')], ])->sum('pago_efectivo') + Movimiento::where([ ['estado_movimiento_id','=', $tipo_movimiento], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')], ])->sum('pago_tarjeta') + Movimiento::where([ ['estado_movimiento_id','=', $tipo_movimiento], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')], ])->sum('pago_vales') + Movimiento::where([ ['estado_movimiento_id','=', $tipo_movimiento], [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')], ])->sum('pago_transferencia'); } public function validarCaja() { if(!CajaMovimiento::cajaInicial()->count()) { $this->cajaModal = true; } } public function save() { $this->validate([ 'cajaInicial' => 'required|numeric', ]); CajaMovimiento::create([ 'cantidad' => $this->cajaInicial, 'estado_caja_movimiento_id' => CajaMovimiento::CODIGO_CAJA, 'user_id' => auth()->user()->id, ]); $this->cajaModal = false; } }