PHP code example of we-are-neopix / laravel-model-translation
1. Go to this page and download the library: Download we-are-neopix/laravel-model-translation 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/ */
we-are-neopix / laravel-model-translation example snippets
$post = BlogPost::find(1); // An instance of the BlogPost model
App::setLocale('sr');
$post->title = 'Naslov na srpskom';
$post->save();
$post->setLanguage('en');
$post->title = 'Title in English';
$post->save();
$post->title; // Returns 'Title in English';
$post->setLanguage('sr')->title; // Returns 'Naslov na srpskom'