Update ShowServicios.php
This commit is contained in:
@@ -178,16 +178,21 @@ class ShowServicios extends Component
|
|||||||
$cantidad_restante = $servicio_tarifa->pantallas - $cantidad_solicitada;
|
$cantidad_restante = $servicio_tarifa->pantallas - $cantidad_solicitada;
|
||||||
|
|
||||||
//Traer todas las cuentas por pantalla 'activo' de los ultimos 15 dias. solo disponibles
|
//Traer todas las cuentas por pantalla 'activo' de los ultimos 15 dias. solo disponibles
|
||||||
$cuentas_pantallas = Cuentas::withCount('historiales')
|
$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('inicio', '>=', $this->fecha)
|
||||||
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
||||||
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
||||||
->where('servicio_id', $servicio_tarifa->id)
|
->where('servicio_id', $servicio_tarifa->id)
|
||||||
->where('estado', 'activo')
|
->where('estado', 'activo')
|
||||||
->havingRaw('historiales_count <= ?', [$cantidad_restante]) // Usar havingRaw
|
->having('historiales_count', '<=', $cantidad_restante)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
||||||
//dd($cuentas_pantallas); // con count da un numero entero
|
//dd($cuentas_pantallas); // con count da un numero entero
|
||||||
|
|
||||||
$cuentas_pantallas_tomadas = Historial_cuenta::whereIn('cuenta_id', $cuentas_pantallas
|
$cuentas_pantallas_tomadas = Historial_cuenta::whereIn('cuenta_id', $cuentas_pantallas
|
||||||
|
|||||||
Reference in New Issue
Block a user