In fact, your $product has no data, because the Eloquent model returns NULL. Probably because you used whereOwnerAndStatus , which seems to be wrong, and if there was data in $product , then this would not work in your first example, because get() returns a collection of several models, but that is not the case. The second example throws an error because foreach did not receive any data. So I think it should be something like this:
$owner = Input::get('owner'); $count = Input::get('count'); $products = Product::whereOwner($owner, 0)->take($count)->get();
In addition, you can also verify that $products has data:
if($product) { return View:make('viewname')->with('products', $products); }
Then in view :
foreach ($products as $product) { // If Product has sku (collection object, probably related models) foreach ($product->sku as $sku) { // Code Here } }
source share