Reputation: 714
I need help with sharing the User resource between Admin and Owner in a panel, without duplicating code or resource. I have created separate panels for each role (Admin App\Filament\Resource\Admin
and Owner App\Filament\Resource\Owner
), but I'm struggling with the User resource as both the admin
and owner
can access it.
I'm working on an admin panel that has separate logins for Admin
and Owner
users, and each user has different permissions. I've been told that policies can help implement this, ensuring role-based access control. Thank you.
Upvotes: 4
Views: 2277
Reputation: 163
i come up with some result using this way:
public function canAccessPanel(\Filament\Panel $panel): bool
{
$user=Auth::user();
if($user->hasRole(RoleEnum::Admin)){
return true;
}
if($user->hasRole(RoleEnum::Researcher) && $panel->getId() === 'researcher'){
return true;
}
if($user->hasRole(RoleEnum::School) && $panel->getId() === 'school'){
return true;
}
return false;
}
but this way user wont redirect to the related panel. wish i could do that too.. but i could not :)
Upvotes: 0