diff --git a/resources/views/components/context-menu.blade.php b/resources/views/components/context-menu.blade.php index 03a4d2c..2a91d63 100644 --- a/resources/views/components/context-menu.blade.php +++ b/resources/views/components/context-menu.blade.php @@ -9,12 +9,12 @@ class="h-6 w-6 ml-auto text-xs tracking-widest text-neutral-400 group-hover:text /> {{ $item->getTitle() }} - - - +{{-- --}} +{{-- --}} +{{-- --}} @endforeach diff --git a/src/ContentMenuItem.php b/src/ContentMenuItem.php index e9d48b7..6231a2c 100644 --- a/src/ContentMenuItem.php +++ b/src/ContentMenuItem.php @@ -2,8 +2,13 @@ namespace AymanAlhattami\FilamentContextMenu; +use Closure; +use Filament\Support\Concerns\EvaluatesClosures; + class ContentMenuItem { + use EvaluatesClosures; + private Closure | string | null $title = null; private Closure | string | null $url = null; @@ -20,7 +25,7 @@ public static function make(): static public function getTitle(): ?string { - return $this->title; + return $this->evaluate($this->title); } public function title(Closure | string | null $title): static @@ -30,9 +35,16 @@ public function title(Closure | string | null $title): static return $this; } + public function translateTitle(): static + { + $this->title = __($this->getTitle()); + + return $this; + } + public function getUrl(): ?string { - return $this->url; + return $this->evaluate($this->url); } public function url(Closure | string | null $url): static @@ -44,7 +56,7 @@ public function url(Closure | string | null $url): static public function getIcon(): ?string { - return $this->icon; + return $this->evaluate($this->icon); } public function icon(Closure | string | null $icon): static @@ -56,7 +68,7 @@ public function icon(Closure | string | null $icon): static public function getTarget(): ?string { - return $this->target; + return $this->evaluate($this->target); } public function target(Closure | string | null $target): static