I've got the following tables in the DB architecture:
My goal is to describe the relation between team, role and permission models. I read the Laravel documentation and there's no way to use the pivot table with 3 relations. Actually, I'll use only 3 relations:
teams
in the User/Player
model)players
in the Team
model)But I don't understand how to use it with laravel relations?
The table team_role_permission
and it's relations have to be, because team creator should be able to edit permissions for his (each) team manually.
possible solution could be storing manually in your pivot table. you should create a model for your pivot table.
$team = Team::create();
$role = Role::create();
$permission = Permission::create();
$pivot = new TeamRolePermission();
$pivot['team_id'] = $team->id;
$pivot['role_id'] = $role->id;
$pivot['permission_id'] = $permission->id;
$pivot->save();