1. Go to this page and download the library: Download simexis/multi-language 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/ */
// models/Country.php
class Country extends Model
{
use \Simexis\MultiLanguage\Traits\Translatable;
public $translatedAttributes = ['name'];
protected $fillable = ['code', 'name'];
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'countries';
}
// models/CountryTranslation.php
use Illuminate\Database\Eloquent\Model;
class CountryTranslation extends Model
{
public $timestamps = false;
protected $fillable = ['name'];
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'country_translations';
}
namespace App\Models;
class Country extends Model
{
use \Simexis\MultiLanguage\Traits\Translatable;
public $translatedAttributes = ['name'];
protected $fillable = ['code', 'name'];
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'countries';
//convention for the translation model is `CountryTranslation`.
public $translationModel = 'MyApp\Models\CountryAwesomeTranslation';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.