46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
use App\Models\Venta;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Livewire\Component;
|
|
|
|
class DashboardController extends Component
|
|
{
|
|
const ESTADO_VENTA =1, ESTADO_ABONO = 2, ESTADO_CANCELACION = 3;
|
|
public function render()
|
|
{
|
|
$venta = $this->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');
|
|
}
|
|
}
|