I am new to Laravel (5.1), and am wondering if I am not using model results in the right way. E.g. below is some of my code in a view. I get the results I want, but the page currently loads quite slowly. I'm wondering if it's because it queries the database repeatedly/separately for every line below? E.g. should I store $item->sessions into a temporary PHP variable (say $x), then do $x->classes->some_column, etc?
Any advice greatly appreciated, thanks a lot in advance.
@foreach ($items as $item)
@if ($item->sessions->classes->some_column== 0)
{{$item->sessions->location}}
@else
{{$item->sessions->classes->suburb}}, {{$item->sessions->classes->state}}
@endif
Much more code that uses $item-> ...
@endforeach