<?php
|
|
namespace app\common\model\plus\operations;
|
|
use app\common\model\BaseModel;
|
|
/**
|
* 运营中心角色模型
|
*/
|
class Role extends BaseModel
|
{
|
protected $name = 'operations_role';
|
protected $pk = 'role_id';
|
|
/**
|
* 关联权限
|
* @return \think\model\relation\HasMany
|
*/
|
public function access()
|
{
|
return $this->hasMany('RoleAccess', 'role_id', 'role_id');
|
}
|
|
/**
|
* 获取详情
|
*/
|
public static function detail($role_id)
|
{
|
return (new static())->with(['access'])->find($role_id);
|
}
|
|
/**
|
* 获取角色列表
|
*/
|
public static function getList($where = [])
|
{
|
$model = new static();
|
if(!empty($where)){
|
$model = $model->where($where);
|
}
|
return $model->order(['sort' => 'asc', 'create_time' => 'desc'])->select();
|
}
|
}
|