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:
Ümit Tunç
2026-01-01 09:58:31 +03:00
parent 5aa2a3d6e5
commit 10f2e9c9bb
@@ -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(),