Download the PHP package workup/nova-translatable without Composer
On this page you can find all versions of the php package workup/nova-translatable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download workup/nova-translatable
More information about workup/nova-translatable
Files in workup/nova-translatable
Package nova-translatable
Short Description A Laravel Nova field for spatie/laravel-translatable.
License MIT
Informations about the package nova-translatable
Nova Translatable Field
Adds the ability to show and edit translated fields created with spatie/laravel-translatable package.
It will show up in the detail view like this:
And in the edit view like this:
Alternative with support for more field types
If you need support for more field types to be translated, take a look at the official package from spatie: https://github.com/spatie/nova-translatable
Installation and usage
You can require this package using composer:
You can add the field follows:
Make sure, that you have your Eloquent model setup correct:
- First, you need to add the
Spatie\Translatable\HasTranslations
-trait. - Next, you should create a public property
$translatable
which holds an array with all the names of attributes you wish to make translatable. - Finally, you should make sure that all translatable attributes are set to the
text
-datatype in your database. If your database supportsjson
-columns, use that.
Here's an example of a prepared model:
Defining Locales
Locales can be defined via config file (config file can be created via spatie/laravel-translatable package) by adding a array:
Alternatively you can "override" the config locales with the method:
Single Line Option
By default the input field on the edit view is a textarea. If you want to change it to a single line input field you can add the option:
Trix Editor
You can use the trix editor for your translated fields by using the option:
Index View
By default the locale used when displaying the field on the index view is determined by . To override this you can use the option: