PHP code example of optimistdigital / nova-translatable

1. Go to this page and download the library: Download optimistdigital/nova-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/ */

    

optimistdigital / nova-translatable example snippets


// Any Nova field
Text::make('Name')
  ->rules('ield
Multiselect::make('Football teams')
  ->rules('n')
  ->translatable([
    'en' => 'English',
    'et' => 'Estonian',
  ]),

use Outl1ne\NovaTranslatable\HandlesTranslatable;

class Product extends Resource
{
    use HandlesTranslatable;

    public function fields(Request $request)
    {
        return [
            Text::make(__('Name'), 'name')
                ->sortable()
                ->translatable()
                ->rules(['max:255'])
                ->rulesFor('en', [
                    '

// in app/Providers/NovaServiceProvider.php

public function boot()
{
    Nova::serving(function () {
        Nova::provideToScript([
            // ...
            'customLocaleDisplay' => [
                'en' => <img src="/flag-en.png"/>,
                'et' => <img src="/flag-et.png"/>,
            ]
        ]);
    });
}
bash
php artisan vendor:publish --tag="nova-translatable-config"