From 195cff6d62c321c7e3b0512f8e4637c3c9b035b2 Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Sat, 1 Jun 2024 20:33:24 -0500 Subject: [PATCH] Update ShowTop.php --- app/Http/Livewire/ShowTop.php | 45 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/app/Http/Livewire/ShowTop.php b/app/Http/Livewire/ShowTop.php index 2365ad2..bb610d2 100755 --- a/app/Http/Livewire/ShowTop.php +++ b/app/Http/Livewire/ShowTop.php @@ -18,29 +18,36 @@ class ShowTop extends Component use LivewireAlert; public function render() - { - $this->configuracion = Configuracione::orderby('id', 'desc')->first(); +{ + $this->configuracion = Configuracione::orderby('id', 'desc')->first(); - $monthYear = date('m-Y', strtotime('last month')); - $month = $this->showLastMonth ? date('m', strtotime('last month')) : date('m'); + $currentYear = date('Y'); + $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) { - $query->whereMonth('fecha_inicio', $month)->where('estado', 'activo'); - }]) - ->withCount(['historiales_venta' => function ($query) use ($month) { - $query->whereMonth('fecha_inicio', $month); - }]) - ->orderBy('historiales_venta_count', 'desc') - ->limit(10) - ->get(); + $consulta_ventas = User::with(['historiales_venta' => function ($query) use ($month, $currentYear) { + $query->whereMonth('fecha_inicio', $month) + ->whereYear('fecha_inicio', $currentYear) + ->where('estado', 'activo'); + }]) + ->withCount(['historiales_venta' => function ($query) use ($month, $currentYear) { + $query->whereMonth('fecha_inicio', $month) + ->whereYear('fecha_inicio', $currentYear); + }]) + ->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() {