Skip to content

Commit 8d4b665

Browse files
Update HasResourceTaxonomy.php
1 parent d02846e commit 8d4b665

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

packages/core/src/Traits/Taxonomy/HasResourceTaxonomy.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,7 @@ protected static function createTaxonomyField(string $taxonomy, array $settings,
9898

9999
return Select::make($taxonomy)
100100
->multiple()
101-
->options(fn () => app($modelClass)::query()
102-
->when(method_exists($modelClass, 'with'), fn ($query) => $query->with('translations'))
103-
->get()
104-
->mapWithKeys(function ($item) {
105-
if (method_exists($item, 'translate')) {
106-
$locale = request()->query('lang', app()->getLocale());
107-
$translation = $item->translate($locale) ?? $item->translate(app()->getLocale());
108-
109-
return [$item->id => $translation ? $translation->title : 'ID: '.$item->id];
110-
}
111-
112-
return [$item->id => $item->title];
113-
})
114-
->toArray()
115-
)
101+
->options(fn () => app($modelClass)::get()->mapWithKeys(fn ($item) => [$item->id => $item->title])->toArray())
116102
->getSearchResultsUsing(
117103
fn (string $search) => app($modelClass)::query()
118104
->when(method_exists($modelClass, 'with'), fn ($query) => $query->with('translations'))

0 commit comments

Comments
 (0)