update
This commit is contained in:
39
application/admin/model/AuthGroup.php
Normal file
39
application/admin/model/AuthGroup.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user