From 21f11eb2dc6cae24f50f17989d1980121612abf2 Mon Sep 17 00:00:00 2001 From: Senexis Date: Mon, 13 Jan 2025 11:41:42 +0100 Subject: [PATCH 1/2] Fix multiple items being added when the title collides. --- src/Livewire/MenuPanel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Livewire/MenuPanel.php b/src/Livewire/MenuPanel.php index b82f53d..7c0f990 100644 --- a/src/Livewire/MenuPanel.php +++ b/src/Livewire/MenuPanel.php @@ -77,7 +77,7 @@ public function add(): void $order = $this->menu->menuItems->max('order') ?? 0; $selectedItems = collect($this->items) - ->filter(fn ($item) => in_array($item['title'], $this->data)) + ->filter(fn ($item) => in_array($item['linkable_id'] ?? $item['title'], $this->data)) ->map(function ($item) use (&$order) { return [ ...$item, @@ -102,7 +102,7 @@ public function add(): void public function form(Form $form): Form { - $items = collect($this->getItems())->mapWithKeys(fn ($item) => [$item['title'] => $item['title']]); + $items = collect($this->getItems())->mapWithKeys(fn ($item) => [$item['linkable_id'] ?? $item['title'] => $item['title']]); return $form ->schema([ From 402664b497b08bd746d3ed76937268df4b0961c6 Mon Sep 17 00:00:00 2001 From: Senexis Date: Mon, 13 Jan 2025 11:42:01 +0100 Subject: [PATCH 2/2] [Minor] Add missing methods in MenuPanel contact. --- src/Contracts/MenuPanel.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Contracts/MenuPanel.php b/src/Contracts/MenuPanel.php index 4f0f42e..862584d 100644 --- a/src/Contracts/MenuPanel.php +++ b/src/Contracts/MenuPanel.php @@ -13,4 +13,16 @@ public function getName(): string; public function getItems(): array; public function getSort(): int; + + public function getDescription(): ?string; + + public function getIcon(): ?string; + + public function isCollapsible(): bool; + + public function isCollapsed(): bool; + + public function isPaginated(): bool; + + public function getPerPage(): int; }