Revert "Update ShowServicios.php"

This reverts commit b864eda936.
This commit is contained in:
lizandrogd
2025-04-02 01:13:42 -05:00
parent b864eda936
commit 5fa0eecf8c
+9 -7
View File
@@ -178,17 +178,19 @@ 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::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)
->whereDate('vencimiento', '>=', $this->fecha_final_1)
->whereDate('vencimiento', '<=', $this->fecha_final_2)
->where('servicio_id', $servicio_tarifa->id)
->where('estado', 'activo')
->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)
->havingRaw('historiales_count <= ?', [$cantidad_restante])
->get();
//dd($cuentas_pantallas); // con count da un numero entero