51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace addons\webman\model;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class AdminRole
|
|
* @property int id 主键
|
|
* @property string name 权限角色名称
|
|
* @property string desc 备注说明
|
|
* @property string sort 排序
|
|
* @property string data_type 数据权限类型:0=全部数据权限,1=自定义数据权限,2=本部门及以下数据权限,3=本部门数据权限,4=本人数据权限
|
|
* @property int type 1 总后台 2渠道后台
|
|
* @property string created_at 创建时间
|
|
* @property string updated_at 最后一次修改时间
|
|
*
|
|
* @package addons\webman\model
|
|
*/
|
|
class AdminRole extends Model
|
|
{
|
|
CONST ROLE_CHANNEL = 3; // 渠道管理员角色
|
|
|
|
CONST DATA_TYPE_ALL = 0; // 全部数据权限
|
|
CONST DATA_TYPE_CUSTOM = 1; // 自定义数据权限
|
|
CONST DATA_TYPE_DEPARTMENT_BELOW = 2; // 本部门及以下数据权限
|
|
CONST DATA_TYPE_DEPARTMENT = 3; // 本部门数据权限
|
|
CONST DATA_TYPE_SELF = 4; // 本人数据权限
|
|
|
|
public function __construct(array $attributes = [])
|
|
{
|
|
parent::__construct($attributes);
|
|
$this->setTable(plugin()->webman->config('database.role_table'));
|
|
}
|
|
/**
|
|
* 部门
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
*/
|
|
public function department(){
|
|
return $this->belongsToMany(plugin()->webman->config('database.department_model'),plugin()->webman->config('database.role_department_model'), 'role_id', 'department_id');
|
|
}
|
|
protected function setCheckStrictlyAttribute($value)
|
|
{
|
|
$this->attributes['check_strictly'] = (int)$value;
|
|
}
|
|
protected function getCheckStrictlyAttribute($value)
|
|
{
|
|
return (boolean)$value;
|
|
}
|
|
}
|