Download the PHP package thenonsensefactory/translate without Composer
On this page you can find all versions of the php package thenonsensefactory/translate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thenonsensefactory/translate
More information about thenonsensefactory/translate
Files in thenonsensefactory/translate
Package translate
Short Description A little package to translate what you need in a model and provide to the user the translate field following the App Locale
License MIT
Homepage https://github.com/bertog/Translate.git
Informations about the package translate
Translate
A very simple package to translate everything you need in a Laravel Model and present to the user the field in the language set in the application
Installation
Via Composer
Usage
First run the needed migration:
Now your database have a new table called 'translations'
In order to have a model Transatable add the relative Trait
Then you have to declare what you need to translate in the $translatable array. This is a mandatory step.
To Save a new translation you can do in this way:
To save multiple translations for the same model (es. in a store method of a Controller) you can use the storeMultipleTranslations method
For sake of simplicity this method if found an existent translation it update the record. If you want to use a more specific o readable method yo can use:
The magic came when you access to the field you have declared as Translatable. The package return the translation in the current App language if present or fallback in the Model table data.
You have a Query Scope and a useful help method
The Array that you have to give to the updateOrCreateTranslation method must be in this shape:
field => text
for example:
['title' => 'My Fancy Title Updated']
Change log
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
- The Nonsense Factory
- All Contributors
License
license. Please see the license file for more information.