init project

This commit is contained in:
2026-05-25 11:08:52 +07:00
commit 85c4b769cc
417 changed files with 67702 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Models\Traits;
trait HasLocalizedName
{
//
public function getNameAttribute()
{
$locale = app()->getLocale(); // e.g. 'en' or 'fr'
// Default fallback language
$column = 'name_en';
if (in_array($locale, ['en', 'kh'])) {
$column = "name_{$locale}";
}
// Return localized name if exists, else fallback
return $this->{$column} ?? $this->name_en;
}
}