PHP code example of kongulov / nova-tab-translatable
1. Go to this page and download the library: Download kongulov/nova-tab-translatable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kongulov / nova-tab-translatable example snippets
use Kongulov\NovaTabTranslatable\NovaTabTranslatable;
...
public function fields(Request $request)
{
return [
ID::make()->sortable(),
NovaTabTranslatable::make([
SluggableText::make('Title')->slug('Slug'),
Slug::make('Slug')->readonly(),
Trix::make('text'),
Text::make('Keywords'),
Text::make('Description'),
]),
];
}
return [
/*
* The source of supported locales on the application
* Available selection "array", "database". Default array
*/
'source' => 'array',
/*
* If you choose array selection, you should add all supported translation on it as "code"
*/
'locales' => [
'en', 'fr', 'es'
],
/*
* If you choose database selection, you should choose the model responsible for retrieving supported translations
* And choose the 'code_field' for example "en", "fr", "es"...
*/
'database' => [
'model' => 'App\\Models\\Language',
'code_field' => 'lang',
'sort_by' => 'id',
'sort_direction' => 'asc'
],
/*
* If you want to save the tab in the last selected language for the whole project, set this "true".
* But if you want to use in one place call the saveLastSelectedLang(true|false) method
*/
'save_last_selected_lang' => false,
];
use Kongulov\NovaTabTranslatable\NovaTabTranslatable;
...
public function fields(Request $request)
{
return [
ID::make()->sortable(),
NovaTabTranslatable::make([
SluggableText::make('Title')->slug('Slug'),
Slug::make('Slug')->readonly(),
Trix::make('text'),
Text::make('Keywords'),
Text::make('Description'),
]),
];
}