version 1.0
This commit is contained in:
45
app/Http/Livewire/DashboardController.php
Normal file
45
app/Http/Livewire/DashboardController.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user