From b864eda9368e41fde00cdf23eff5a047b1e1ea77 Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 2 Apr 2025 01:06:16 -0500 Subject: [PATCH] Update ShowServicios.php --- app/Http/Livewire/ShowServicios.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/Http/Livewire/ShowServicios.php b/app/Http/Livewire/ShowServicios.php index b59522e..43ae328 100755 --- a/app/Http/Livewire/ShowServicios.php +++ b/app/Http/Livewire/ShowServicios.php @@ -178,19 +178,17 @@ 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::select('cuentas.*') - ->selectSub(function ($query) { - $query->from('historiales') - ->join('historial_cuentas', 'historiales.id', '=', 'historial_cuentas.historial_id') - ->whereColumn('historial_cuentas.cuenta_id', 'cuentas.id') - ->selectRaw('count(*)'); - }, 'historiales_count') - ->whereDate('inicio', '>=', $this->fecha) + $cuentas_pantallas = Cuentas::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') - ->havingRaw('historiales_count <= ?', [$cantidad_restante]) + ->where(function ($query) use ($cantidad_restante) { + $query->selectRaw('count(*)') + ->from('historiales') + ->join('historial_cuentas', 'historiales.id', '=', 'historial_cuentas.historial_id') + ->whereColumn('historial_cuentas.cuenta_id', 'cuentas.id'); + }, '<=', $cantidad_restante) ->get(); //dd($cuentas_pantallas); // con count da un numero entero