I\'ve got this in my Laravel webapp:
@foreach($mentors as $mentor)
@foreach($mentor->intern as $intern)
-
You can always count the collection. For example $mentor->intern->count()
will return how many intern does a mentor have.
https://laravel.com/docs/5.2/collections#method-count
In your code you can do something like this
foreach($mentors as $mentor)
@if($mentor->intern->count() > 0)
@foreach($mentor->intern as $intern)
{{ $intern->employee->FirstName }}
{{ $intern->employee->LastName }}
@endforeach
@else
Mentor don't have any intern
@endif
@endforeach
- 热议问题