File tree Expand file tree Collapse file tree 6 files changed +61
-1
lines changed Expand file tree Collapse file tree 6 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ return new class extends Migration
15
15
$table->string('code')->unique();
16
16
$table->text('description')->nullable();
17
17
$table->string('style')->default('default');
18
+ $table->integer('max_depth')->nullable();
18
19
$table->timestamps();
19
20
20
21
// Index for code lookups
Original file line number Diff line number Diff line change 68
68
'description_help ' => 'Optional description for content managers. Not displayed to website visitors. ' ,
69
69
'style_lbl ' => 'Menu Style ' ,
70
70
'style_help ' => 'Choose the visual style for this menu. This affects how the menu is displayed on the frontend. ' ,
71
+ 'max_depth_lbl ' => 'Maximum depth ' ,
72
+ 'max_depth_help ' => 'Maximum number of menu levels allowed (1-10). Leave blank to use the global default. ' ,
71
73
],
72
74
'table ' => [
73
75
'name_col ' => 'Name ' ,
74
76
'code_col ' => 'Code ' ,
75
77
'style_col ' => 'Style ' ,
78
+ 'max_depth_col ' => 'Max depth ' ,
79
+ 'default_depth ' => 'Default ' ,
76
80
'items_count_col ' => 'Items ' ,
77
81
'created_at_col ' => 'Created at ' ,
78
82
],
Original file line number Diff line number Diff line change 68
68
'description_help ' => 'Optionele beschrijving voor contentbeheerders. Wordt niet getoond aan websitebezoekers. ' ,
69
69
'style_lbl ' => 'Menu Stijl ' ,
70
70
'style_help ' => 'Kies de visuele stijl voor dit menu. Dit beïnvloedt hoe het menu wordt weergegeven op de frontend. ' ,
71
+ 'max_depth_lbl ' => 'Maximale diepte ' ,
72
+ 'max_depth_help ' => 'Maximaal aantal menu niveaus toegestaan (1-10). Laat leeg om de globale standaard te gebruiken. ' ,
71
73
],
72
74
'table ' => [
73
75
'name_col ' => 'Naam ' ,
74
76
'code_col ' => 'Code ' ,
75
77
'style_col ' => 'Stijl ' ,
78
+ 'max_depth_col ' => 'Max diepte ' ,
79
+ 'default_depth ' => 'Standaard ' ,
76
80
'items_count_col ' => 'Items ' ,
77
81
'created_at_col ' => 'Aangemaakt op ' ,
78
82
],
Original file line number Diff line number Diff line change 9
9
use Statikbe \FilamentFlexibleContentBlocks \Models \Concerns \HasCodeTrait ;
10
10
use Statikbe \FilamentFlexibleContentBlocks \Models \Contracts \HasCode ;
11
11
12
+ /**
13
+ * @property int $id
14
+ * @property string $name
15
+ * @property string $code
16
+ * @property string|null $description
17
+ * @property string $style
18
+ * @property int|null $max_depth
19
+ * @property \Carbon\Carbon $created_at
20
+ * @property \Carbon\Carbon $updated_at
21
+ * @property \Illuminate\Database\Eloquent\Collection<\Statikbe\FilamentFlexibleContentBlockPages\Models\MenuItem> $menuItems
22
+ * @property \Illuminate\Database\Eloquent\Collection<\Statikbe\FilamentFlexibleContentBlockPages\Models\MenuItem> $allMenuItems
23
+ */
12
24
class Menu extends Model implements HasCode
13
25
{
14
26
use HasCodeTrait;
@@ -19,6 +31,7 @@ class Menu extends Model implements HasCode
19
31
'code ' ,
20
32
'description ' ,
21
33
'style ' ,
34
+ 'max_depth ' ,
22
35
];
23
36
24
37
public function getTable ()
@@ -56,4 +69,10 @@ public function getEffectiveStyle(): string
56
69
57
70
return FilamentFlexibleContentBlockPages::config ()->getDefaultMenuStyle ();
58
71
}
72
+
73
+ public function getEffectiveMaxDepth (): int
74
+ {
75
+ // Return the menu's max_depth if set, otherwise fall back to config default
76
+ return $ this ->max_depth ?? FilamentFlexibleContentBlockPages::config ()->getMenuMaxDepth ();
77
+ }
59
78
}
Original file line number Diff line number Diff line change @@ -79,6 +79,14 @@ public static function form(Form $form): Form
79
79
->helperText (flexiblePagesTrans ('menus.form.style_help ' ));
80
80
}
81
81
82
+ $ formFields [] = TextInput::make ('max_depth ' )
83
+ ->label (flexiblePagesTrans ('menus.form.max_depth_lbl ' ))
84
+ ->numeric ()
85
+ ->minValue (1 )
86
+ ->maxValue (10 )
87
+ ->placeholder (FilamentFlexibleContentBlockPages::config ()->getMenuMaxDepth ())
88
+ ->helperText (flexiblePagesTrans ('menus.form.max_depth_help ' ));
89
+
82
90
$ formFields [] = Textarea::make ('description ' )
83
91
->label (flexiblePagesTrans ('menus.form.description_lbl ' ))
84
92
->rows (3 )
@@ -116,6 +124,13 @@ public static function table(Table $table): Table
116
124
->color ('gray ' )
117
125
->visible (fn () => count (FilamentFlexibleContentBlockPages::config ()->getMenuStyles ()) > 1 ),
118
126
127
+ TextColumn::make ('max_depth ' )
128
+ ->label (flexiblePagesTrans ('menus.table.max_depth_col ' ))
129
+ ->formatStateUsing (function (?int $ state ): string {
130
+ return $ state ? (string ) $ state : flexiblePagesTrans ('menus.table.default_depth ' );
131
+ })
132
+ ->sortable (),
133
+
119
134
TextColumn::make ('menuItems_count ' )
120
135
->label (flexiblePagesTrans ('menus.table.items_count_col ' ))
121
136
->counts ('menuItems ' )
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ class ManageMenuItems extends TreePage
22
22
23
23
protected static string $ resource = MenuResource::class;
24
24
25
+ protected static int $ modelMaxDepth ;
26
+
25
27
public mixed $ menu ;
26
28
27
29
public function mount (): void
@@ -216,6 +218,21 @@ protected function getFormSchema(): array
216
218
217
219
public static function getMaxDepth (): int
218
220
{
219
- return FilamentFlexibleContentBlockPages::config ()->getMenuMaxDepth () ?? 3 ;
221
+ if (! isset (static ::$ modelMaxDepth )) {
222
+ // Since this is static, we need to get the menu from the current request
223
+ $ recordId = request ()->route ('record ' );
224
+ if ($ recordId ) {
225
+ $ menuModelClass = MenuResource::getModel ();
226
+ $ menu = app ($ menuModelClass )->find ($ recordId );
227
+ if ($ menu ) {
228
+ return $ menu ->getEffectiveMaxDepth ();
229
+ }
230
+ }
231
+
232
+ // Fallback to global config if we can't determine the menu
233
+ static ::$ modelMaxDepth = FilamentFlexibleContentBlockPages::config ()->getMenuMaxDepth () ?? 3 ;
234
+ }
235
+
236
+ return static ::$ modelMaxDepth ;
220
237
}
221
238
}
You can’t perform that action at this time.
0 commit comments