Refactor Product Form Localization: Updated the category options in the ProductForm to utilize the translation function for titles, enhancing localization support and ensuring consistent display of category names across different languages.
This commit is contained in:
@@ -34,10 +34,7 @@ class ProductForm
|
||||
->label(__('products.category'))
|
||||
->options(function () {
|
||||
return ProductCategory::all()->mapWithKeys(function ($category) {
|
||||
$title = is_array($category->title)
|
||||
? ($category->title[app()->getLocale()] ?? \Illuminate\Support\Arr::first($category->title))
|
||||
: $category->title;
|
||||
return [$category->id => $title ?? ('Category #' . $category->id)];
|
||||
return [$category->id => $category->translate('title') ?? ('Category #' . $category->id)];
|
||||
});
|
||||
})
|
||||
->searchable(),
|
||||
|
||||
Reference in New Issue
Block a user