Update ShowTop.php

This commit is contained in:
lizandrogd
2024-06-01 20:33:24 -05:00
parent 903c6fba79
commit 195cff6d62
+12 -5
View File
@@ -21,20 +21,26 @@ class ShowTop extends Component
{ {
$this->configuracion = Configuracione::orderby('id', 'desc')->first(); $this->configuracion = Configuracione::orderby('id', 'desc')->first();
$currentYear = date('Y');
$monthYear = date('m-Y', strtotime('last month')); $monthYear = date('m-Y', strtotime('last month'));
$month = $this->showLastMonth ? date('m', strtotime('last month')) : date('m'); $month = $this->showLastMonth ? date('m', strtotime('last month')) : date('m');
$consulta_ventas = User::with(['historiales_venta' => function ($query) use ($month) { $consulta_ventas = User::with(['historiales_venta' => function ($query) use ($month, $currentYear) {
$query->whereMonth('fecha_inicio', $month)->where('estado', 'activo'); $query->whereMonth('fecha_inicio', $month)
->whereYear('fecha_inicio', $currentYear)
->where('estado', 'activo');
}]) }])
->withCount(['historiales_venta' => function ($query) use ($month) { ->withCount(['historiales_venta' => function ($query) use ($month, $currentYear) {
$query->whereMonth('fecha_inicio', $month); $query->whereMonth('fecha_inicio', $month)
->whereYear('fecha_inicio', $currentYear);
}]) }])
->orderBy('historiales_venta_count', 'desc') ->orderBy('historiales_venta_count', 'desc')
->limit(10) ->limit(10)
->get(); ->get();
$consultaPremioEntregado = PremioEntregado::where('fecha', $monthYear)->first(); $consultaPremioEntregado = PremioEntregado::whereYear('fecha', $currentYear)
->where('fecha', $monthYear)
->first();
return view('livewire.show-top', [ return view('livewire.show-top', [
'usuarios' => $consulta_ventas, 'usuarios' => $consulta_ventas,
@@ -42,6 +48,7 @@ class ShowTop extends Component
]); ]);
} }
public function entregarPremio() public function entregarPremio()
{ {
$monthYear = date('m-Y', strtotime('last month')); $monthYear = date('m-Y', strtotime('last month'));