Reputation: 13
Currently trying to display a list of all objects in a collection subfleets
I am using the get
command but only returns the first object:
<tr>
<td>@lang('flights.subfleets')</td>
<td>{{ $flight->subfleets->get(0)->name }}</td>
</tr>
Upvotes: 0
Views: 75
Reputation: 59
See https://laravel.com/docs/5.8/blade#loops
@foreach($flight->subfleets as $subFleet)
<tr>
<td>{{ $subFleet->name }}</td>
</tr>
@endforeach
Upvotes: 1
Reputation: 1932
You should iterate $flight->subfleets->get() using @foreach;
@foreach($flight->subfleets->get() as $subFleet)
<tr>
<td>{{ $subFleet->name }}</td>
</tr>
@endforeach
Upvotes: 0