多语言
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id 主键
|
||||
* @property integer $rule_id 规则ID
|
||||
* @property string $lang 语言代码
|
||||
* @property string $title 翻译标题
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
*/
|
||||
class RuleTranslation extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_rule_translations';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* 获取规则的翻译标题
|
||||
* @param int $ruleId 规则ID
|
||||
* @param string $lang 语言代码
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getTranslatedTitle($ruleId, $lang)
|
||||
{
|
||||
$translation = self::where('rule_id', $ruleId)
|
||||
->where('lang', $lang)
|
||||
->first();
|
||||
|
||||
return $translation ? $translation->title : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user