anekdotes / polyglot
简化 Illuminate 模型本地化的抽象模型。
1.1.1
2016-10-14 13:19 UTC
Requires
- php: >=5.6.0
- anekdotes/support: <2.0.0
Requires (Dev)
- phpunit/phpunit: ~5.4
This package is auto-updated.
Last update: 2024-09-13 03:24:09 UTC
README
简化 Illuminate 模型本地化的抽象模型。
安装
通过 composer 在项目中安装
composer require anekdotes/polyglot
用法
使用类扩展您希望翻译的模型
class Test extends TranslatedModel
将所需的翻译列添加到 polyglot 数组中(locale 必须存在)
protected $polyglot = ['locale', 'title', 'description', 'slug'];
别忘了也将翻译列添加到 fillable 数组中
protected $fillable = ['rank', 'locale', 'title', 'description', 'slug'];
创建一个新文件,最好是 Lang.php,并扩展 Illuminate Model
class TestLang extends Model
将翻译列添加到 fillable 数组中,并将时间戳设置为 false
protected $fillable = ['locale', 'title', 'description', 'slug']; public $timestamps = false;