Configure Models - nevadskiy/laravel-translatable GitHub Wiki
Add the HasTranslations
trait of the strategy you want to use to your model that you want to make translatable.
For example, let's use the Extra Table Extended strategy:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Nevadskiy\Translatable\Strategies\ExtraTableExtended\HasTranslations;
class Book extends Model
{
use HasTranslations;
}
And you also need to specify which attributes should be translatable using the translatable
array:
/**
* The attributes that are translatable.
*
* @var array
*/
protected $translatable = [
'title',
'description',
];
That's all. Final model may look like this:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Nevadskiy\Translatable\Strategies\ExtraTableExtended\HasTranslations;
class Book extends Model
{
use HasTranslations;
protected $translatable = [
'title',
'description',
];
}