Manipulating and saving Laravel Eloquent models in multiple languages
laravel model translation is a good package for manipulating and saving Laravel Eloquent models in multiple languages.
This package is meant to simplify the process of making Eloquent models translatable. It's aim is to deviate as little as possible from Laravel's Eloquent API but still provide a satisfiable level of flexibility. This is achieved by utilizing a driver-based approach to storing translations and a trait which allows Model instances to seamlessly interact with the translation storage.
$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'
This post is submitted by one of our members. You may submit a new post here.