What is the best way to connect two many-to-many (belongsToMany) together in laravel? -
i have 2 working many-to-many (belongstomany) relations. looking third connection connects these 2 relations together. doing myself in manual way wonder if there built in laravel way. plus efficient , proper way accomplish this?
here short presentation of tables:
users name email password role_user role_id user_id roles name permission_role permission_id role_id permissions name route
the users table related roles belongstomany using role_user pivot table, permissions table related roles table using permission_role table. okay how relate users , permissions together. how can $permissions = app\user::find(1)->permissions()->get();
done in laravel way.
i can't use hasmanythrough relation because none of tables users, roles , permissions have relating columns users.role_id or roles.user_id use
Comments
Post a Comment