Update ShowTop.php

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