Files
Background-panel/application/admin/model/AuthGroup.php
yyh931018@qq.com 1b0c8f4196 update
2022-09-08 15:32:32 +08:00

40 lines
826 B
PHP

<?php
namespace app\admin\model;
use app\common\model\Area;
use think\Model;
class AuthGroup extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 追加属性
protected $append = [
'city_text',
];
public function getNameAttr($value, $data)
{
return __($value);
}
public function getCityTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['city']) ? $data['city'] : '');
$list = $this->getCityList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getCityList()
{
return Area::where('pid', 655)->column('name','id');
}
}