3 years ago

Getting Collection from Lazy Loading but and showing attributes on Blade.php

Posted 3 years ago by jsrosas

Hi All, I have an issue I cant figure out. I am lazy loading a relation like this. a Member has many Users, User has many Orders. So I am calling from within the model.

public function clientOrders(){
        return $clientOrders;

Then I pass it to the view through the controller with compact('clientOrders');

                           @foreach ($clientOrders as $client)

But I get

Undefined property: Illuminate\Database\Eloquent\Collection::$stripe_id

Even though when I do {{$client->order}} I get the full list of attributes.

[{"id":12,"user_id":83,"stripe_id":"or_18djYKKR0gYurAdXUWb1N0kr","email":"[email protected]","amount":29700,"sku":"sophia1","product":"Sophia1","quantity":3,"address_1":"123 test","address_2":null,"city":"951","zip":"65432","country":"United States","status":"created","created_at":"2016-08-01 12:48:37","updated_at":"2016-08-01 12:48:37"}]

Please sign in or create an account to participate in this conversation.