anekdotes/polyglot

简化 Illuminate 模型本地化的抽象模型。

1.1.1 2016-10-14 13:19 UTC

This package is auto-updated.

Last update: 2024-09-13 03:24:09 UTC


README

Latest Stable Version Build Status codecov.io StyleCI License Total Downloads

简化 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;