version 1.0

This commit is contained in:
Guillermo Gutierrez
2023-08-11 11:08:47 -07:00
commit 994709a3e5
223 changed files with 23438 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?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');
}
}