Instead of creating multiple tables and handling translations via a different table, this package uses a single table and a JSON column to store the translations.
Installation
Installation guide for this package is really simple and consists only of two steps:
Require the package via composer:
composer require spatie/laravel-translatable
And for the models you want to translate add the Spatie\Translatable\HasTranslations
trait with $translatable
property:
Model
use Spatie\Translatable\HasTranslations; class Post extends Model{ use HasTranslations; public $translatable = ['title'];}
That is it! Now if you set up the database column title
to be a JSON column (or TEXT in unsupported databases), you can start using the package.
Usage
Here's a quick example of how we used this package:...