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
Was it helpful?

Solution

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

$artifacts = Artifact::with('product')->get();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top