I have a collection with relationships ->toArray() that looks something like this:
$phone = Phone::with('reviews','specifications','retailers')->first()->toArray();
Now if there is only one review it breaks my foreach in the view why is this?
@foreach($phone['reviews'] as $r) // html @endforeach
I don't want to have to do a condition as it would mean repeating loads of html
@if(count($phone['reviews'] >=0) // print out single review //html @else // loop through @foreach($phone['reviews'] as $r) // html @endforeach @endif
seems a little silly any ideas why the foreach won't work with only 1 element in the $phone['reviews'] array?
thanks in advance