Skip to content

Commit

Permalink
Merge pull request #3 from megoxv/master
Browse files Browse the repository at this point in the history
Add option to allow Route in Menu Items
  • Loading branch information
3x1io authored Dec 22, 2024
2 parents e4e265e + 520880f commit 12b8bd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/FilamentMenusPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ public function getId(): string
return 'filament-menus';
}

public static bool $allowRoute = true;

public function allowRoute(bool $condition = true): static
{
self::$allowRoute = $condition;
return $this;
}

public function register(Panel $panel): void
{
if(class_exists(Module::class) && \Nwidart\Modules\Facades\Module::find('FilamentMenus')?->isEnabled()){
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/MenuResource/Relations/MenuItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public function form(Form $form): Form
->deletable(false)
->label(trans('filament-menus::messages.cols.item.title')),
Forms\Components\Toggle::make('is_route')
->default(true)
->hidden(!filament('filament-menus')::$allowRoute)
->default(false)
->label(trans('filament-menus::messages.cols.item.is_route'))
->required()
->live(),
Expand Down Expand Up @@ -141,8 +142,7 @@ public function form(Form $form): Form
])
->label(trans('filament-menus::messages.cols.item.badge_color')),
IconPicker::make('icon')
->label(trans('filament-menus::messages.cols.item.icon'))
->required(),
->label(trans('filament-menus::messages.cols.item.icon')),
Forms\Components\Toggle::make('new_tab')
->label(trans('filament-menus::messages.cols.item.target'))
->required(),
Expand Down

0 comments on commit 12b8bd5

Please sign in to comment.