PHP code example of optimistdigital / nova-lang

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


// in app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        new \OptimistDigital\NovaLang\NovaLang
    ];
}

// in /config/nova-lang.php

// ...
'locales' => [
  'en' => 'English',
  'et' => 'Estonian',
],

// OR

'locales' => function () {
  return Locale::all()->pluck('name', 'key');
},


$locales = nova_lang_get_all_locales();

//or you can use it in another package.

'locales' => nova_lang_get_all_locales(),

$fields[] = NovaLangField::make('Locale', 'locale');

$fields[] = NovaLangField::make('Locale', 'locale', 'locale_parent_id')

//Your resource file, where you have returned $fields array
public static function indexQuery(NovaRequest $request, $query)
{
    $localeColumn = 'your_table_name' . 'locale'
    $query->where(function ($subQuery) use ($localeColumn) {
        $subQuery->where($localeColumn, nova_lang_get_active_locale())
            ->orWhereNotIn($localeColumn, array_keys(nova_lang_get_all_locales()));
    });
    return $query;
}
bash
php artisan vendor:publish --provider="OptimistDigital\NovaLang\ToolServiceProvider" --tag="config"