Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
foreach in foreach in if blade php
@foreach ($capacityGroups as $capacityGroupFather)

@foreach ($exampleProjects as $k => $exampleProject)

@foreach ($exampleProject->capacityGroups as $j => $exampleCapacity)

@if ($exampleCapacity->id == $capacityGroupFather->id)

Only the first result of the loop

<div class="carousel-item active">

The rest of the loop

<div class="carousel-item">

We have the example Projects collection, each of which has capacityGroups. I need to bring all the example Projects for each capacity Group. But the first of each goes into a special div (carousel-item active) and the rest of each goes into (carousel-item) how can I fix this problem

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Simply use the loop variable.

@foreach ($exampleProjects as $k => $exampleProject)
    <div class="carousel-item{{ $loop->first ? ' active' : '' }}">
    </div>
@endforeach
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda