mercredi 4 mai 2016

laravel link up 3 tables

i have 3 tables: users, roles, permission while two tables: role_users and permission_role are storing the keys

A users belongs to many roles. In App\user.php, i can retrieve the roles (i only retrieve one role is needed even the relationship is many)

public function roles()
{
    //return $this->belongsToMany('App\Role')->withTimestamps();
    return $this->belongsToMany('App\Role', 'role_user', 'user_id', 'role_id');
}

A roles has many permissions, but how can i retrieve the permissions via user?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1UyiGEH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire