1. Go to this page and download the library: Download mosaiqo/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/ */
namespace App;
use Jenssegers\Mongodb\Model;
class Article extends Model
{
use \Mosaiqo\Translatable\Traits\Translatable;
protected $fillable = ['commentable'];
/**
* This are the attributes you want to have in multiple languages.
*/
protected $translatableAttributes = ['title', 'slug'];
/**
* This is optional by default it will search for App\ArticleLocale.
*/
protected $translationModel = 'Mosaiqo\Translatable\Tests\Models\ArticleLocale';
}
namespace App;
use Jenssegers\Mongodb\Model;
class ArticleLocale extends Eloquent
{
protected $fillable = ['title', 'slug'];
}
$article = Article::create([
'commentable' => true,
'published' => true,
'en' => [
'title' => 'My title',
'body' => 'This is the text for my new post ...'
]
]);
$article = Article::create([
'commentable' => true
]);
$article->en([
'title' => 'My title',
'body' => 'This is the text for my new post ...'
]);
$article->es([
'title' => 'Mi titulo',
'body' => 'Este es mi texto para mi nuevo post ...'
]);