You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have some resources which users with certain roles are allowed to see a subset of, but can't see all of.
For example, we want users to be able to view the CashLedgerEntry resource index when the model's recorder_id matches the authenticated user's id.
This is easy to achieve in our model policies:
public function viewAny(User $user)
{
if ($user->hasPermissionTo(Permission::ViewAnyCashLedgerEntry)) {
return true;
}
}
public function view(User $user, CashLedgerEntry $cashLedgerEntry)
{
if ($user->id === $cashLedgerEntry->recorder_id || $user->hasPermissionTo(Permission::ViewAnyCashLedgerEntry)) {
return true;
}
}
The problem is that in Nova, users can't see the menu link for the "Cash Ledger Entry" resource at all unless they have the ViewAnyCashLedgerEntry permission.
Ideally, these users would still be able to see the menu link, but that resource index page would only show the models they're authorized to see.
I think this boils down to two questions:
Is there any way to control the visibility of the navigation link besides viewAny()?
I understand that we can use indexQuery() to scope the results on the index view, but we'd only need to do this when the user does not have the ViewAnyCashLedgerEntry permission. If that is possible, how would it be done?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
We have some resources which users with certain roles are allowed to see a subset of, but can't see all of.
For example, we want users to be able to view the
CashLedgerEntry
resource index when the model'srecorder_id
matches the authenticated user's id.This is easy to achieve in our model policies:
The problem is that in Nova, users can't see the menu link for the "Cash Ledger Entry" resource at all unless they have the
ViewAnyCashLedgerEntry
permission.Ideally, these users would still be able to see the menu link, but that resource index page would only show the models they're authorized to see.
I think this boils down to two questions:
viewAny()
?indexQuery()
to scope the results on the index view, but we'd only need to do this when the user does not have theViewAnyCashLedgerEntry
permission. If that is possible, how would it be done?Thanks so much for any guidance on this.
Beta Was this translation helpful? Give feedback.
All reactions