update:更新模块列表

This commit is contained in:
JaguarJack 2020-10-12 14:00:40 +08:00
parent 3908c26e2c
commit bcb96cd3c4

View File

@ -1,6 +1,7 @@
<?php <?php
namespace catchAdmin\system\controller; namespace catchAdmin\system\controller;
use catchAdmin\permissions\model\Permissions;
use catcher\base\CatchController; use catcher\base\CatchController;
use catcher\CatchResponse; use catcher\CatchResponse;
use catcher\CatchAdmin; use catcher\CatchAdmin;
@ -23,13 +24,20 @@ class Module extends CatchController
$modules[] = json_decode(file_get_contents($d . 'module.json'), true); $modules[] = json_decode(file_get_contents($d . 'module.json'), true);
} }
$hasModules = array_unique(Permissions::whereIn('id', request()->user()->getPermissionsBy())->column('module'));
$orders = array_column($modules, 'order'); $orders = array_column($modules, 'order');
array_multisort($orders, SORT_DESC, $modules); array_multisort($orders, SORT_DESC, $modules);
return CatchResponse::success($modules); foreach ($modules as $k => $module) {
} if (!in_array($module['alias'], $hasModules)) {
unset($modules[$k]);
}
}
return CatchResponse::success(array_values($modules));
}
/** /**
* 禁用/启用模块 * 禁用/启用模块