Question

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
Était-ce utile?

La solution

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

$artifacts = Artifact::with('product')->get();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top