Test with:
Message::find(1)->userfrom()->first()->username;
//or
Message::find(1)->userfrom->username;
Works with Message::find(1)->userfrom()->first()->username;
, thanks.
I figured why it didn't work with Eloquent's dynamic properties: I named the method after the column (userfrom
), so $message->userfrom
returned the actual column and didn't called the relationship method.
I renamed it from()
and now Message::find(1)->from->username
works well!
Great
Yeah, Relationship names have be different of properties.
Edit the post and put as Solved.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community