init project

This commit is contained in:
2026-05-25 11:08:52 +07:00
parent a388c619b5
commit 895fdd9b83
1437 changed files with 384844 additions and 27 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;
}
}