corbosman started a new conversation+100 XP
5mos ago
Hi all, I'm working on a small inhouse app to manage an authorization matrix we need for ISO requirements. We need to manage documentation on all apps, and which users/roles have access to what application and with what level. I have the following tables:
- Users
- Roles (A user has many Roles) (Things like CEO, Developer, Operations, etc)
- Applications
- Permissions (things like "admin", "user", "none" to keep it simple)
So there is a user-roles relationship, and then an application-permission-role 3 way relationship.
What I'd like is on the Application Resource, be able to edit which Roles have what permissions. I did kind of solve it. What I did was create a relationship on Role only, and added the Permission as an additional pivot column. It works, but it feels a bit clunky. I also tried using a Repeater Form, which also does somewhat work, but I liked it even less. I'll add my current RolesRelationManager on the ApplicationResource:
return $table
->recordTitleAttribute('slug')
->columns([
TextColumn::make('slug')
->searchable(),
TextColumn::make('pivot.permission.name')
])
->filters([
//
])
->headerActions([
AttachAction::make()
->label('Authorize')
->schema(fn (AttachAction $action): array => [
$action->getRecordSelect(),
Select::make('permission_id')
->label('Permission')
->searchable()
->options(fn () => Permission::orderBy('name')->pluck('name', 'id'))
->required(),
])
->preloadRecordSelect()
->modalSubmitActionLabel('Authorize')
])
->recordActions([
DetachAction::make()
->label('Deauthorize')
]);
How would you solve this? Is there a better way?
And as a second question. I need to generate a page where we basically see the full Matrix. So Y column would be apps, and X column is Roles, with each cell being the permission. Can this be done as a page?
Thanks