update
This commit is contained in:
@@ -278,62 +278,37 @@ class ShowPromociones extends Component
|
||||
$this->fecha_final_1 = $today = Carbon::now()->addDays($tarifa->dias - 20);
|
||||
$this->fecha_final_2 = $today = Carbon::now()->addDays($tarifa->dias + 20);
|
||||
|
||||
/* $cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
$baseQuery = Cuentas::select('*')->where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
||||
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
||||
->Orderby('inicio', 'ASC')->with('historiales')
|
||||
->withCount('historiales')
|
||||
->where('estado', 'pendiente')
|
||||
->having('historiales_count', '==', 0)
|
||||
->first(); */
|
||||
->where('estado', 'pendiente');
|
||||
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
||||
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
||||
->where('estado', 'pendiente')
|
||||
$cuenta = Cuentas::fromSub($baseQuery, 'alias')
|
||||
->where('historiales_count', '==', 0)
|
||||
->orderBy('inicio', 'ASC')
|
||||
->with('historiales') // Relación de historiales
|
||||
->withCount('historiales') // Contar historiales
|
||||
->first();
|
||||
|
||||
if ($cuenta) {
|
||||
// Filtrar la cuenta si tiene 0 historiales
|
||||
if ($cuenta->historiales_count != 0) {
|
||||
$cuenta = null; // Si
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
/* $cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->Orderby('inicio', 'ASC')
|
||||
->with('historiales')
|
||||
->withCount('historiales')
|
||||
->where('estado', 'activo')
|
||||
->having('historiales_count', '<=', (int) $faltante)
|
||||
->first(); */
|
||||
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
$baseQuery = Cuentas::select('*')->where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->where('estado', 'activo')
|
||||
->Orderby('inicio', 'ASC')
|
||||
->with('historiales')
|
||||
->withCount('historiales')
|
||||
->where('estado', 'activo');
|
||||
|
||||
$cuenta = Cuentas::fromSub($baseQuery, 'alias')
|
||||
->where('historiales_count', '<=', (int) $faltante)
|
||||
->orderBy('inicio', 'ASC')
|
||||
->with('historiales') // Relación de historiales
|
||||
->withCount('historiales') // Contar historiales
|
||||
->first();
|
||||
|
||||
if ($cuenta && $cuenta->historiales_count <= (int) $faltante) {
|
||||
// La cuenta cumple con el filtro, puedes usarla.
|
||||
} else {
|
||||
// La cuenta no cumple con el filtro, la descartas o manejas según sea necesario.
|
||||
$cuenta = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!is_null($cuenta)) {
|
||||
$perfil = $cuenta->historiales_count;
|
||||
for ($y = 0; $y < (int) $pantallas_tarifa; $y++) {
|
||||
|
||||
Reference in New Issue
Block a user