Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!