Skip to content

Commit

Permalink
Merge pull request #27 from Log1x/enhance/dont-save-model-menu-urls-i…
Browse files Browse the repository at this point in the history
…n-db

🧑‍💻 Ensure model menu item URLs do not get saved to the database
  • Loading branch information
datlechin authored Aug 20, 2024
2 parents a76aeb2 + 4c39899 commit 902b90d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions resources/lang/en/menu-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
'form' => [
'title' => 'Title',
'url' => 'URL',
'linkable_type' => 'Type',
'linkable_id' => 'ID',
],
'resource' => [
'name' => [
Expand Down Expand Up @@ -47,6 +49,7 @@
],
],
'items' => [
'expand' => 'Expand',
'empty' => [
'heading' => 'There are no items in this menu.',
],
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/vi/menu-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
'form' => [
'title' => 'Tiêu đề',
'url' => 'URL',
'linkable_type' => 'Loại',
'linkable_id' => 'ID',
],
'resource' => [
'name' => [
Expand Down Expand Up @@ -47,6 +49,7 @@
],
],
'items' => [
'expand' => 'Mở rộng',
'empty' => [
'heading' => 'Không có mục nào trong menu này.',
],
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/menu-item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class="flex justify-between px-3 py-2 bg-white shadow-sm rounded-xl ring-1 ring-
<x-filament::icon-button
icon="heroicon-o-chevron-right"
x-on:click="open = !open"
title="Mở rộng"
:tooltip="trans('filament-menu-builder::menu-builder.items.expand')"
color="gray"
class="transition duration-200 ease-in-out"
x-bind:class="{ 'rotate-90': open }"
Expand Down
9 changes: 6 additions & 3 deletions src/Livewire/MenuItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Get;
use Filament\Support\Enums\ActionSize;
use Filament\Support\Enums\MaxWidth;
use Filament\Support\Facades\FilamentIcon;
Expand Down Expand Up @@ -89,14 +90,16 @@ public function editAction(): Action
->label(__('filament-menu-builder::menu-builder.form.title'))
->required(),
TextInput::make('url')
->hidden(fn (?string $state): bool => empty($state))
->hidden(fn (?string $state, Get $get): bool => blank($state) || filled($get('linkable_type')))
->label(__('filament-menu-builder::menu-builder.form.url'))
->required(),
Placeholder::make('linkable_type')
->hidden(fn (?string $state): bool => empty($state))
->label(__('filament-menu-builder::menu-builder.form.linkable_type'))
->hidden(fn (?string $state): bool => blank($state))
->content(fn (string $state) => $state),
Placeholder::make('linkable_id')
->hidden(fn (?string $state): bool => empty($state))
->label(__('filament-menu-builder::menu-builder.form.linkable_id'))
->hidden(fn (?string $state): bool => blank($state))
->content(fn (string $state) => $state),
Select::make('target')
->label(__('filament-menu-builder::menu-builder.open_in.label'))
Expand Down

0 comments on commit 902b90d

Please sign in to comment.