Skip to content

Commit 2e81e41

Browse files
committed
Improve menu item tree layout
1 parent 73c90bb commit 2e81e41

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Models/MenuItem.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Statikbe\FilamentFlexibleContentBlockPages\Models;
44

5+
use Illuminate\Database\Eloquent\Casts\Attribute;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -111,7 +112,14 @@ public function getMorphClass()
111112

112113
public static function getTreeLabelAttribute(): string
113114
{
114-
return 'label';
115+
return 'tree_label';
116+
}
117+
118+
protected function treeLabel(): Attribute
119+
{
120+
return Attribute::make(
121+
get: fn (string $value) => $this->getDisplayLabel(),
122+
);
115123
}
116124

117125
public function getTreeCaption(): string

src/Resources/MenuResource/Pages/ManageMenuItems.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public static function getModel(): string|QueryBuilder
5454
protected function getViewData(): array
5555
{
5656
$query = static::getModel()::scoped(['menu_id' => $this->record->id])
57+
->with('linkable')
5758
->defaultOrder();
5859

5960
return [

0 commit comments

Comments
 (0)