laravel 5 pivot table -
i'm trying implement friendlist user user can have many friends
but calling friends i'm having problem getting relation right:
user id friends user_id friend_user_id class user:
public function friends(){ homecoming $this->hasmany('app\user', 'friends'); } so auth::user()->friends should homecoming list of user models
you don't have "one many" relationship rather "many many" friends beingness joining table
try this:
public function friends(){ homecoming $this->belongstomany('app\user', 'friends', 'user_id', 'friend_user_id'); } laravel laravel-5
No comments:
Post a Comment