Download the PHP package organi/translatables without Composer
On this page you can find all versions of the php package organi/translatables. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package translatables
Installation
You can install the package via composer:
You can publish and run the migrations with:
You can publish the config file with:
This is the contents of the published config file:
Usage
Make your eloquent model translatable.
Create a _translations
table for your model.
Add the HasTranslations
trait to your model and a localizable
array containing the translatable fields.
Setting translatable fields
Now you can add a translation to the name attribute of your model.
You can also set an array and the model will turn it in a translation:
You can also set the property to anything other than an array. In this case the default locale of the application will be set with the value.
Or set multiple translations for a single locale
Or set a single translation for a single locale
Or set a single string for all locales
Getting translatable fields
Getting a translatable fields will return a Translation
object.
Converting it to a string will automatically take the value of the active locale. Some options are:
Or you can get a specific locale:
Filtering on a translatable fields
This package provides a whereTranslation
function.
Ordering on a translatable fields
This package provides a orderByTranslation
function.
The function has 3 parameters:
field
: field that should be used for the orderinglocale
: locale that should be used for the orderingdirection
(optional defaults toasc
):asc
ordesc
All versions of translatables with dependencies
spatie/laravel-package-tools Version ^1.4.3
illuminate/contracts Version ^8.0|^9.0
illuminate/support Version ^8.0|^9.0
illuminate/database Version ^8.0|^9.0
illuminate/bus Version ^8.0|^9.0
illuminate/queue Version ^8.0|^9.0
illuminate/console Version ^8.0|^9.0