PHP code example of guidocella / laravel-multilingual

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

    

guidocella / laravel-multilingual example snippets




Schema::create('countries', function (Blueprint $table)
{
	$table->increments('id');
	$table->json('name');
});



class Country extends Model
{
    use GuidoCella\Multilingual\Translatable;

    public $translatable = ['name'];
}



Country::create([
	'name' => [
		'en' => 'Spain',
		'es' => 'España'
	]
]);

$country->name

$country->nameTranslations->en

$country->nameTranslations->toArray()

$country->update(['name->'.App::getLocale() => 'Spain']);



$validator = validator(
    ['name' => ['en' => 'One', 'es' => 'Uno']],
    ['name.en' => '



$validator = validator(
    ['name' => ['en' => 'One', 'es' => 'Uno']],
    ['name' => 'translatable_

'translatable_

Company::where('name->en', 'Monsters Inc.')->first();

Country::orderBy('name->'.App::getLocale())->get();
sh
php artisan vendor:publish