esign/laravel-underscore-translatable
title_en, title_nl) for translations, avoiding complex JSON-based storage (unlike Spatie’s json approach).title_en, title_es), which may increase database size and complexity for high-cardinality locales.WHERE title_en = 'foo'), requiring workarounds._en, _nl suffixes to columns).created_at).laravel-localization) if needed.en)?['en', 'nl', 'fr']).title_en, title_nl).Schema::table('posts', function (Blueprint $table) {
$table->string('title_en')->nullable()->after('title');
$table->string('title_nl')->nullable()->after('title_en');
});
UnderscoreTranslatable trait and define $translatable.class Post extends Model {
use UnderscoreTranslatable;
public $translatable = ['title', 'description'];
}
title to title_en).Post::query()->each(function ($post) {
$post->setTranslations(['en' => ['title' => $post->title]]);
$post->save();
});
en) to validate the pattern.nl, fr).en if nl is missing).Post::whereTranslation('title', 'en', 'foo')).ALTER TABLE, EXPLAIN) work out of the box.title_xx).Column 'title_en' not found).SELECT title_en FROM posts).public function getTitleAttribute($value) {
$locale = app()->getLocale();
return cache()->remember("post.{$this->id}.title.{$locale}", now()->addHours(1), function () {
return $this->{"title_{$locale
How can I help you explore Laravel packages today?