新增超级管理员判断&权限范围

This commit is contained in:
JaguarJack
2020-07-04 21:56:47 +08:00
parent e798098a05
commit 9092b64c1f
2 changed files with 24 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
<?php
namespace catchAdmin\permissions\model;
use catcher\Utils;
trait DataRangScopeTrait
{
/**
@@ -13,7 +15,17 @@ trait DataRangScopeTrait
*/
protected function dataRange($roles)
{
return $this->whereIn($this->aliasField('creator_id'), $this->getDepartmentUserIdsBy($roles));
if (Utils::isSuperAdmin()) {
return $this;
}
$userIds = $this->getDepartmentUserIdsBy($roles);
if (empty($userIds)) {
return $this;
}
return $this->whereIn($this->aliasField('creator_id'), $userIds);
}
/**