Reusing same Resource in multiple panels?

Hey, I'm building a multi tenant site, and I have 2 panels - the admin panel and tenant panel. I want to reuse the same Resource (or is that bad?) in both panels, but the permissions should be different. Admin panel would require view_any permission while the tenant panel should have "manage_own" permission required to access the list view of the resource. I'm thinking I can add the canViewAny() method on the resource and conditionally check the current panel, but it seems it is not possible to get current panel? Something like this:
public static function canViewAny(): bool
{
return currentPanel === 'admin' ? $user->can('view_any') : $user->can('manage_own');
}
public static function canViewAny(): bool
{
return currentPanel === 'admin' ? $user->can('view_any') : $user->can('manage_own');
}
Or what would be the suggest approach for this?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server