Monday, March 20, 2017

Laravel - can't access an object property

I have the following code:

foreach($items as $item) {
            if (sizeof($item->craft)) {
                foreach ($item->craft as $craftItem)
                    return $craftItem;
            }
        }

The output is the following JSON:

enter image description here

When I'm trying to access the req_item from the code, laravel outputs nothing. I'm trying to do it by changing:

return $craftItem to:

return $craftItem->req_item

If I'm trying to output any other property other than req_item (such as id,item_id,quantity) - laravel do return the right value.

Any idea why I can't access the req_item object?



via TheUnreal

Advertisement