resource-navigation-tab
resource-navigation-tab copied to clipboard
Hide/Show Tab
Is there a way to hide/show tab based on rules i.e. permissions or any other rules based on the values of a Resource?
You can always do something like this:
class ExampleNovaResource extends Resource {
public function fields(Request $request)
{
if($request->user()->can(.....)) {
return [
ResourceNavigationTab::make([ 'label' => 'Only for admin' ]),
];
}
return [
ResourceNavigationTab::make([ 'label' => 'Public' ]),
];
}
}
Thanks. But what if its needs to show or hide by Resource values I.e. I have Pages and you can clone them. Only for pages that have been cloned I want a tab that shows which pages were the clone (children parent relationship)
On Tue, 23 Feb 2021, 13:03 Rafael Milewski, [email protected] wrote:
You can always do something like this:
class ExampleNovaResource extends Resource {
public function fields(Request $request) { if($request->user()->can(.....)) { return [ ResourceNavigationTab::make([ 'label' => 'Only for admin' ]), ]; } return [ ResourceNavigationTab::make([ 'label' => 'Public' ]), ]; }
}
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dcasia/resource-navigation-tab/issues/35#issuecomment-784118214, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKWBB2XLECX3ZL65HA5WFLTAODO5ANCNFSM4YCH4NJQ .
I think its still the same concept, you dynamically build the array of fields based on your condition.. if you need 3 tabs.. return 3 instances of ResourceNavigationTab
.. so on..