新增超级管理员判断&权限范围
This commit is contained in:
parent
e798098a05
commit
9092b64c1f
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace catchAdmin\permissions\model;
|
namespace catchAdmin\permissions\model;
|
||||||
|
|
||||||
|
use catcher\Utils;
|
||||||
|
|
||||||
trait DataRangScopeTrait
|
trait DataRangScopeTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -13,7 +15,17 @@ trait DataRangScopeTrait
|
|||||||
*/
|
*/
|
||||||
protected function dataRange($roles)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,4 +118,15 @@ class Utils
|
|||||||
{
|
{
|
||||||
return \config('database.connections.mysql.prefix');
|
return \config('database.connections.mysql.prefix');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是超级管理员
|
||||||
|
*
|
||||||
|
* @time 2020年07月04日
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isSuperAdmin()
|
||||||
|
{
|
||||||
|
return request()->user()->id == config('catch.permissions.super_admin_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user