feat: 对非超级用户隐藏

This commit is contained in:
JaguarJack 2023-04-06 21:33:36 +08:00
parent 858c4d0929
commit 2a43fa0591
2 changed files with 15 additions and 2 deletions

View File

@ -27,7 +27,13 @@ class UserController extends Controller
*/
public function index()
{
return $this->user->getList();
return $this->user->setBeforeGetList(function ($query){
if (! $this->getLoginUser()->isSuperAdmin()) {
return $query->where('id', '<>', config('catch.super_admin'));
}
return $query;
})->getList();
}
/**

View File

@ -70,6 +70,13 @@ class User extends Model implements AuthenticatableContract
);
}
protected function DepartmentId(): Attribute
{
return new Attribute(
get: fn($value) => $value ? : null
);
}
/**
* is super admin
*