how to access protected array values ?

帅比萌擦擦* 提交于 2019-12-01 16:05:42

save the object in a variable and do a foreach loop,

foreach($cart as $item) {
    echo $item->name;
    echo $item->options->brand;
}

if that's not working, you can use the fetch method from the collection class.

http://laravel.com/api/5.0/Illuminate/Support/Collection.html#method_fetch

$item->fetch('name');

and the package you're using has a alternate method search

$item->search('name');
$item->search(['options' => 'name'])

https://github.com/Crinsane/LaravelShoppingcart/blob/master/src/Gloudemans/Shoppingcart/CartRowOptionsCollection.php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!