cambio real
This commit is contained in:
@@ -285,13 +285,37 @@ class MenuController extends Controller
|
||||
//dd($cantidad_tarjetaPlan);
|
||||
if((int)$pantalla_servicio_completa >= (int)$cantidad_solicitada ){
|
||||
$suma = $pantalla_servicio-$cantidad_solicitada;
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $fecha)
|
||||
->where('estado', 'activo')
|
||||
->orderBy('created_at', 'ASC')
|
||||
->withCount('historiales') // Contar los historiales
|
||||
->first();
|
||||
|
||||
$cuenta = Cuentas::where('servicio_id',$servicio_id)->whereDate('inicio','>=',$fecha)->Orderby('created_at', 'ASC')->withCount('historiales')->where('estado','activo')->having('historiales_count', '<=', $suma)->first();
|
||||
if ($cuenta && $cuenta->historiales_count <= $suma) {
|
||||
// La cuenta cumple con el filtro de cantidad de historiales.
|
||||
} else {
|
||||
// La cuenta no cumple con el filtro (tiene más historiales de los permitidos o no existe).
|
||||
$cuenta = null;
|
||||
}
|
||||
|
||||
}elseif((int)$pantalla_servicio_completa == (int)$cantidad_solicitada){
|
||||
$this->fecha_final_1 = $today = Carbon::now()->addDays($pantallas->dias-15);
|
||||
$this->fecha_final_2 = $today = Carbon::now()->addDays($pantallas->dias+15);
|
||||
//completas
|
||||
$cuenta = Cuentas::where('servicio_id',$this->servicio_id)->whereDate('inicio','>=',$this->fecha)->whereDate('vencimiento','>=',$this->fecha_final_1)->whereDate('vencimiento','<=',$this->fecha_final_2)->Orderby('created_at', 'ASC')->withCount('historiales')->where('estado','pendiente')->having('historiales_count', '==', 0)->first();
|
||||
$cuentas = Cuentas::where('servicio_id', $this->servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
||||
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
||||
->orderBy('created_at', 'ASC')
|
||||
->withCount('historiales') // Contar los historiales
|
||||
->where('estado', 'pendiente') // Filtrar por estado pendiente
|
||||
->get(); // Obtener todas las cuentas que coincidan con los filtros
|
||||
|
||||
$cuenta = $cuentas->first(function ($cuenta) {
|
||||
return $cuenta->historiales_count == 0; // Filtrar solo cuentas que no tengan historiales
|
||||
});
|
||||
|
||||
}else{
|
||||
$cuenta=null;
|
||||
}
|
||||
@@ -332,7 +356,17 @@ class MenuController extends Controller
|
||||
|
||||
for ($h=0; $h < (int)$cantidad_tarjetaPlan ; $h++) {
|
||||
//dd($n);
|
||||
$cuenta = Cuentas::where('servicio_id',$servicio_id)->whereDate('inicio','>=',$fecha)->Orderby('created_at', 'ASC')->with('historiales')->withCount('historiales')->where('estado','activo')->having('historiales_count', '<=', (int)$suma2)->first();
|
||||
$cuentas = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $fecha)
|
||||
->orderBy('created_at', 'ASC')
|
||||
->with('historiales') // Obtener los historiales relacionados
|
||||
->withCount('historiales') // Contar los historiales asociados
|
||||
->where('estado', 'activo') // Filtrar por estado 'activo'
|
||||
->get(); // Obtener todas las cuentas que coincidan con los filtros
|
||||
$cuenta = $cuentas->first(function ($cuenta) use ($suma2) {
|
||||
return $cuenta->historiales_count <= (int)$suma2; // Filtrar por el número de historiales
|
||||
});
|
||||
|
||||
//dd($cuenta);
|
||||
if (!empty($cuenta)) {
|
||||
$perfil = $cuenta->historiales_count;
|
||||
@@ -381,9 +415,34 @@ class MenuController extends Controller
|
||||
if ($pantalla_servicio_completa == $pantallas_tarifa) {
|
||||
$this->fecha_final_1 = $today = Carbon::now()->addDays($tarifa->dias-15);
|
||||
$this->fecha_final_2 = $today = Carbon::now()->addDays($tarifa->dias+15);
|
||||
$cuenta = Cuentas::where('servicio_id',$servicio_id)->whereDate('inicio','>=',$fecha)->whereDate('vencimiento','>=',$this->fecha_final_1)->whereDate('vencimiento','<=',$this->fecha_final_2)->Orderby('created_at', 'ASC')->with('historiales')->withCount('historiales')->where('estado','pendiente')->having('historiales_count', '==', 0)->first();
|
||||
$cuentas = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $fecha)
|
||||
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
||||
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
||||
->orderBy('created_at', 'ASC')
|
||||
->with('historiales') // Relación con los historiales
|
||||
->withCount('historiales') // Contar los historiales
|
||||
->where('estado', 'pendiente') // Filtrar por estado 'pendiente'
|
||||
->get(); // Obtener todas las cuentas que coincidan con los filtros
|
||||
|
||||
$cuenta = $cuentas->first(function ($cuenta) {
|
||||
return $cuenta->historiales_count == 0; // Filtrar solo cuentas que no tengan historiales
|
||||
});
|
||||
|
||||
}else{
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)->whereDate('inicio','>=',$fecha)->Orderby('created_at', 'ASC')->with('historiales')->withCount('historiales')->where('estado', 'activo')->having('historiales_count', '<=', (int)$faltante)->first();
|
||||
$cuentas = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $fecha)
|
||||
->orderBy('created_at', 'ASC')
|
||||
->with('historiales') // Relación con los historiales
|
||||
->withCount('historiales') // Contar los historiales asociados
|
||||
->where('estado', 'activo') // Filtrar por el estado 'activo'
|
||||
->get(); // Obtener todas las cuentas que cumplan con los filtros
|
||||
|
||||
$cuenta = $cuentas->first(function ($cuenta) use ($faltante) {
|
||||
return $cuenta->historiales_count <= (int) $faltante;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
//dd($tarifa);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user