Download the PHP package lechihuy/laratrans without Composer
On this page you can find all versions of the php package lechihuy/laratrans. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lechihuy/laratrans
More information about lechihuy/laratrans
Files in lechihuy/laratrans
Package laratrans
Short Description Support multiple language resources for Laravel.
License MIT
Homepage https://github.com/lechihuy/laratrans
Informations about the package laratrans
Laratrans
Support multiple language resources for Laravel.
Docs
Installation
After you install the package successfully, open your terminal at your project and run the following command:
Configuration
You can configure the package in app/config/translatable.php, please read it to detail more.
Database
...
Model
Imaginary, you need to apply translation for Post model.
First, use the Laratrans\Translatable trait in Post model file as bellow:
Next, open your terminal and run the following command to create translation model:
The Translation namespace must be corresponding with translation_namespace in the configuration file. Besides, the suffix of translation model name must be Translation.
Post model need to translate title, description columns. You simple declare the translatedAttributes property in this model.
You need to declare eager loading to it work. The package that offers two eager loadings are translations and translation.
If you serialize a translatable model with translations eager loading, the response can be given as bellow:
Otherwise, if you use translation eager loading, the response won't contain translations property.
You also hidden a few redundant properties if you want via $hidden property in the model.
License
Laratrans is open-sourced software licensed under the MIT license.