문제

I've got a controller exposing object-data to a view:

$artifacts = Artifact::with('product');
return View::make('index', compact('artifacts'));

This used to work fine until last week. For some reasons now I can't use the data anymore in the template itself.

//this works
<?php
    print_r($artifacts->first());
?>

//this doesnt
@foreach ($artifacts as $artifact)
<?php 
    print_r($artifact);
?>
@endforeach
도움이 되었습니까?

해결책

when using eager loading, you need to get the actual resultset.

$artifacts = Artifact::with('product')->get();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top