1

I wanted to assign a property to the first element of each serie (Value1) and y tried to do with the new Laravel $loop variable but nesting doesn't work. I tried to use $loop->first, but only works one on the first Group.

I tried to do the next:

- Group 1     $loop->index = 0 (parent)
  - Value 1   $loop->index = 0
  - Value 2   $loop->index = 1
  - Value 3   $loop->index = 2

- Group 2     $loop->index = 1 (parent)
  - Value 1   $loop->index = 3
  - Value 2   $loop->index = 4

Seems the $loop->index (child) doesn't start a new serie. What can I do?

1
  • 2
    You should show your code, because it works as expected with simple nested loop. Commented Nov 15, 2016 at 10:27

1 Answer 1

1
@foreach($groups as $group)
    <h3>Group {{ $group->name }}</h3>
    <table>
        <tr>
            <td>SubGroup Name</td>
        </tr>
    @foreach($projects as $project)
        <tr>
            @if($loop->first)
                <td rowspan="{{ $loop->count }}"></td>
            @endif
            <td>Target Language</td>
        </tr>
    @endforeach
    </table>
@endforeach
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.