PHP code example of latevaweb / laravel-translatable
1. Go to this page and download the library: Download latevaweb/laravel-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/ */
latevaweb / laravel-translatable example snippets
$customer = new Customer; // An Eloquent model
$customer
->setTranslation('greeting', 'en', 'Hello')
->setTranslation('greeting', 'es', 'Hola')
->save();
$customer->greeting; // Returns 'Hello' given that the current app locale is 'en'
$customer->getTranslation('greeting', 'es'); // returns 'Hola'
app()->setLocale('es');
$customer->greeting; // Returns 'Hola'