My current nested for loop:
@foreach($auditResults->map->questionDetail as $detail)
@include('dropdownQuestion', [
'answer' => $auditResults,
'detail' => $detail,
'question' => $detail->auditQuestion
])
@endforeach
As you can see, I want to return the $auditResults
within the loop as answer
, but this current set up doesn't work.
If I change the for loop to this (which logically makes sense):
@foreach($auditResults as $result)
@foreach($result->map->questionDetail as $detail)
@include('dropdownQuestion', [
'answer' => $result,
'detail' => $detail,
'question' => $detail->map->auditQuestion
])
@endforeach
@endforeach
I get Trying to get property of non-object
.
How can I loop and return the $auditResults
without getting a non-object property? Many thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire