Skip to content

Commit bbe8862

Browse files
authored
Merge pull request #12 from pschilly/master
Panel Navigation
2 parents a3901ff + f152c85 commit bbe8862

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

config/filament-types.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
'types_resource' => null,
1717

1818
/**
19-
* Show Navigation Menu
20-
*
21-
* If you need to show the navigation menu for the types
19+
* Panel Navigation
20+
* Accepts: boolean OR array of panel ID with boolean
21+
* If array is empty, assumes to not display navigation item.
22+
*
23+
* Panel Example:
24+
* 'panel_navigation' => ['admin' => TRUE];
2225
*/
23-
'show_navigation' => true,
26+
'panel_navigation' => true,
2427

2528
/**
2629
* Empty State

src/Filament/Resources/TypeResource.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Form\TypeForm;
1010
use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeTable;
1111
use TomatoPHP\FilamentTypes\Models\Type;
12+
use Filament\Facades\Filament;
1213

1314
class TypeResource extends Resource
1415
{
@@ -43,6 +44,31 @@ public static function getNavigationGroup(): ?string
4344
return trans('filament-types::messages.group');
4445
}
4546

47+
/**
48+
* Config Item: `panel_navigation`
49+
* Returns: bool
50+
*
51+
* Accepts: array OR bool
52+
*
53+
* Compares against current panel ID based on what is in the array (if provided).
54+
*/
55+
public static function shouldRegisterNavigation(): bool
56+
{
57+
$configItem = config('filament-types.panel_navigation', TRUE);
58+
59+
if (is_array($configItem) && !empty($configItem)) {
60+
foreach (config('filament-types.panel_navigation', true) as $key => $val) {
61+
if (Filament::getCurrentPanel()->getId() === $key) {
62+
return $val;
63+
} else {
64+
return FALSE;
65+
}
66+
}
67+
} else {
68+
return (empty($configItem)) ? FALSE : $configItem;
69+
}
70+
}
71+
4672
public static function form(Form $form): Form
4773
{
4874
return TypeForm::make($form);

0 commit comments

Comments
 (0)