From 9e55cfe4b24108fc876c1e30dcd657ad756556b3 Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 2 Apr 2025 01:00:32 -0500 Subject: [PATCH] Update ShowServicios.php --- app/Http/Livewire/ShowServicios.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Livewire/ShowServicios.php b/app/Http/Livewire/ShowServicios.php index d0a2a8c..77a91d2 100755 --- a/app/Http/Livewire/ShowServicios.php +++ b/app/Http/Livewire/ShowServicios.php @@ -178,13 +178,13 @@ class ShowServicios extends Component $cantidad_restante = $servicio_tarifa->pantallas - $cantidad_solicitada; //Traer todas las cuentas por pantalla 'activo' de los ultimos 15 dias. solo disponibles - $cuentas_pantallas = Cuentas::whereDate('inicio', '>=', $this->fecha) + $cuentas_pantallas = Cuentas::withCount('historiales') // ✅ Primero contar historiales + ->whereDate('inicio', '>=', $this->fecha) ->whereDate('vencimiento', '>=', $this->fecha_final_1) ->whereDate('vencimiento', '<=', $this->fecha_final_2) ->where('servicio_id', $servicio_tarifa->id) ->where('estado', 'activo') - ->withCount('historiales') // ✅ Contamos los historiales - ->having('historiales_count', '<=', $cantidad_restante) // ✅ Filtramos los historiales + ->having('historiales_count', '<=', $cantidad_restante) // ✅ Filtrar usando la cuenta ->get();