Skip to content

Commit 6860e02

Browse files
committed
Fix bug in morph relation of menu item
1 parent 5ccacdb commit 6860e02

File tree

4 files changed

+6
-19
lines changed

4 files changed

+6
-19
lines changed

src/Form/Fields/Types/LinkableMenuItemType.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@ public function searchResultLimit(int $limit): static
4949
return $this;
5050
}
5151

52-
public function getSelectField(): Select
53-
{
54-
return Select::make('linkable_id')
55-
->label(flexiblePagesTrans('menu_items.form.linkable_item_lbl'))
56-
->searchable()
57-
->getSearchResultsUsing(fn (string $search): array => $this->getSearchResults($search))
58-
->getOptionLabelUsing(fn ($value): ?string => $this->getOptionLabel($value))
59-
->required()
60-
->helperText($this->getHelperText());
61-
}
62-
6352
public function getSearchResults(string $search): array
6453
{
6554
$modelClass = $this->model;

src/Form/Forms/MenuItemForm.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected static function getLinkableField(): Select
168168
$type = static::getTypeByAlias($linkType);
169169

170170
if ($type && $type->isModelType() && $state) {
171-
$set(static::FIELD_LINKABLE_TYPE, $type->getModel());
171+
$set(static::FIELD_LINKABLE_TYPE, $type->getAlias());
172172
}
173173
});
174174
}
@@ -270,6 +270,9 @@ protected static function getModelLabelFromResource(string $modelClass): string
270270
return class_basename($modelClass);
271271
}
272272

273+
/**
274+
* @return AbstractMenuItemType[]
275+
*/
273276
protected static function getTypes(): array
274277
{
275278
if (static::$types === null) {

src/Models/MenuItem.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,4 @@ public function isVisible(): bool
111111
{
112112
return $this->is_visible;
113113
}
114-
115-
public function getTitleAttribute(): string
116-
{
117-
return $this->getDisplayLabel();
118-
}
119114
}

src/Resources/MenuResource/Pages/ManageMenuItems.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function getMenuItemTypeDescription(MenuItem $record): string
126126
{
127127
if ($record->linkable_type && $record->linkable) {
128128
// Get model label from Filament resource if available
129-
$modelLabel = $this->getModelLabelFromResource($record->linkable_type);
129+
$modelLabel = $this->getModelLabelFromResource($record->linkable::class);
130130

131131
return flexiblePagesTrans('menu_items.tree.linked_to').' '.$modelLabel;
132132
} elseif ($record->url) {
@@ -194,7 +194,7 @@ public function getTreeRecordIcon(?\Illuminate\Database\Eloquent\Model $record =
194194

195195
// Return appropriate icon based on type
196196
if ($record->linkable_type && $record->linkable) {
197-
return $this->getModelIconFromResource($record->linkable_type) ?: 'heroicon-o-link';
197+
return $this->getModelIconFromResource($record->linkable::class) ?: 'heroicon-o-link';
198198
}
199199

200200
if ($record->url) {

0 commit comments

Comments
 (0)