File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 16
16
'types_resource ' => null ,
17
17
18
18
/**
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];
22
25
*/
23
- 'show_navigation ' => true ,
26
+ 'panel_navigation ' => true ,
24
27
25
28
/**
26
29
* Empty State
Original file line number Diff line number Diff line change 9
9
use TomatoPHP \FilamentTypes \Filament \Resources \TypeResource \Form \TypeForm ;
10
10
use TomatoPHP \FilamentTypes \Filament \Resources \TypeResource \Table \TypeTable ;
11
11
use TomatoPHP \FilamentTypes \Models \Type ;
12
+ use Filament \Facades \Filament ;
12
13
13
14
class TypeResource extends Resource
14
15
{
@@ -43,6 +44,31 @@ public static function getNavigationGroup(): ?string
43
44
return trans ('filament-types::messages.group ' );
44
45
}
45
46
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
+
46
72
public static function form (Form $ form ): Form
47
73
{
48
74
return TypeForm::make ($ form );
You can’t perform that action at this time.
0 commit comments