Download the PHP package folklore/eloquent-localizable without Composer
On this page you can find all versions of the php package folklore/eloquent-localizable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download folklore/eloquent-localizable
More information about folklore/eloquent-localizable
Files in folklore/eloquent-localizable
Package eloquent-localizable
Short Description Laravel 4 and 5 package to add localization capabilities to Eloquent Models
License MIT
Homepage http://github.com/Folkloreatelier/eloquent-localizable
Informations about the package eloquent-localizable
Eloquent Localizable
Simple Laravel 4 and 5 package to add localization capabilities to Eloquent Models
Installation
Dependencies:
Installation:
1- Require the package with Composer
Usage
Configuration
This package use a Trait to add localization capabilities to your Eloquent modal. Basically it will add a locales relation to your model and provide a sync method for easy saving.
For example, if you have a Page model and you would like to add localized title, description. You first add the trait to your Page class.
By default the trait will look for a [MODEL_NAME]Locale model. So in this example, it will looks for a PageLocale. Just create a PageLocale class next to your Page model.
You can change the locale model class by overiding the getLocaleModelClass method.
You also need to create the table for you localization. Following the example, we will create a migration for a pages_locales table.
Getting locales
You can now use the locales relation on your Page model.
Getting a page with all locales
Getting a page with a specific locale
If you want to always include the locales when fetching a page.
Saving locales
You can use the syncLocales method to save your locales.