I wanted to display the value of status
field from the boardings
table which is in a relationship with travel
table. When I do this code:
$travel->boardings->status
it returns an error that says, $status
is undefined.
As you can see boardings
is of type Collection so you can use it with index
$travel->boardings[0]->status
or by using for loop
foreach($travel->boardings as $boarding){
$status = $boarding->status;
}