You're probably returning a collection of users instead of a single user. Can you post the code the performs the user query?
Sep 18, 2015
7
Level 1
Access data 3 tables
Hi, I have 3 tables
users (id, name, lastname)
extra (id, title)
users_extras (id, user_id, extra_id)
If I want to know how extra data from a user I write this in users model
public function extras()
{
return $this->belongsToMany('App\Extras', 'users_extras', 'user_id', 'id');
}
But I have an error "Undefined property: Illuminate\Database\Eloquent\Collection::$extras"
What is wrong, I am new in Laravel.
Thanks
Please or to participate in this conversation.