Add multilingual support to labor categories (RO/RU/EN)

- Migration: adds name_ro, name_ru, name_en columns; copies name→name_ro;
  seeds RU and EN translations for all 11 default categories
- LaborCategory: label() returns localized name, optionsForSelect() keyed
  by canonical name (stored in labors.category) with localized label
- LaborCategoryResource: 3-column form with RO/RU/EN inputs; table shows
  all three columns side by side
- LaborResource: category select and filter use optionsForSelect()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-07 12:37:39 +00:00
parent 818ae29b20
commit 1b34a3c217
4 changed files with 102 additions and 17 deletions
+19 -1
View File
@@ -9,7 +9,25 @@ class LaborCategory extends Model
{
use BelongsToTenant;
protected $fillable = ['company_id', 'name', 'sort_order'];
protected $fillable = ['company_id', 'name', 'name_ro', 'name_ru', 'name_en', 'sort_order'];
protected $casts = ['sort_order' => 'integer'];
/** Localized display label — falls back through ru→en→name_ro→name. */
public function label(?string $locale = null): string
{
$locale = $locale ?: app()->getLocale();
return $this->{"name_{$locale}"}
?: $this->name_ro
?: $this->name
?: '';
}
/** Options array keyed by canonical name (stored in labors.category). */
public static function optionsForSelect(): array
{
return static::orderBy('sort_order')->orderBy('name')->get()
->mapWithKeys(fn ($c) => [$c->name => $c->label()])
->toArray();
}
}