Foreach with two bd lists. blade of Laravel

0

I have read some articles and seen this way, but it is not correct giving the following error:

  

(1/1) ErrorException Undefined offset: 1

@foreach($palpites, $confrontos) as ($p, $c))
  <tr>    
    <td> {{ $p->diadojogo}} </td>
    <td> {{ $p->timea }} </td>
    <td> {{ $c->diadojogo}} </td>
    <td> {{ $c->resultado}} </td>      
  </tr>    
@endforeach
    
asked by anonymous 28.09.2017 / 14:20

1 answer

2

You can use it this way, I believe it will work for your situation:

<table>
    <thead>
        <tr>
            <th>coluna1P</th>
            <th>coluna2P</th>
            <th>coluna1C</th>
            <th>coluna2C</th>
        </tr>
    </thead>
    <tbody>
    @foreach($palpites as $index => $palpite)
        <tr>
            <td> {{ $palpite['diajogo'] }} </td>
            <td> {{ $palpite['timea'] }} </td>
            <td> {{ $confrontos[$index]['diajogo'] }} </td>
            <td> {{ $confrontos[$index]['resultado'] }} </td>
        </tr>
    @endforeach
    </tbody>
</table>

I do not think it will work unless the amount of guesses and clashes is not the same.

    
28.09.2017 / 14:45