<?php
|
|
namespace app\common\model\shop;
|
|
|
use app\common\model\BaseModel;
|
|
/**
|
* 应用模型
|
*/
|
class Role extends BaseModel
|
{
|
protected $name = 'shop_role';
|
protected $pk = 'role_id';
|
|
/**
|
* 获取器
|
*/
|
public function getAreaIdAttr($json)
|
{
|
return json_decode($json, true);
|
}
|
|
/**
|
* 修改器
|
*/
|
public function setAreaIdAttr($data)
|
{
|
return json_encode($data);
|
}
|
|
/**
|
* 关联权限
|
* @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 getAreaIdsByRoleIds($role_ids)
|
{
|
return (new static())->where("role_id","in",$role_ids)->column("area_id");
|
}
|
|
}
|