/** * 查找指定的资源数据 * @param $id * @return DeepinAuthResource * @throws DeepInException */ protected function find($id) { $resource = DeepinAuthResource::find($id); if ($resource instanceof DeepinAuthResource) { return $resource; } else { throw new DeepInException("找不到id为" . $id . "的权限资源数据~!"); } }
/** * 分配权限 * @param $gid * @return \Illuminate\View\View */ public function allocation($gid) { $list = DeepinAuthResource::all(); $data = DeepinAuthPermission::whereRaw("gid=:gid", array(":gid" => $gid))->get(array("resourceid")); $checked = array(); foreach ($data as $item) { $checked[] = $item["resourceid"]; } unset($data); return view("admin.auth.group.allocation", array("list" => $list, "gid" => $gid, "permission" => $checked)); }
/** * 首页列表显示 * @return \Illuminate\View\View */ public function index() { $data = DeepinAuthResource::paginate($this->pageSize); return view("admin.auth.resource.index", array("data" => $data)); }
/** * 收集权限资源 * @param Request $request * @return DeepinAuthResource */ private function processPermissionResource(Request $request) { $routeInfo = explode("@", $request->route()->getActionName()); if (count($routeInfo) != 2) { return null; } $module = $routeInfo[0]; $action = $routeInfo[1]; $resource = DeepinAuthResource::whereRaw("module=:module and action=:action", array(":module" => $module, ":action" => $action))->first(); if (!$resource instanceof DeepinAuthResource) { // 新增 $resource = new DeepinAuthResource(); $resource->module($module); $resource->action($action); $resource->save(); } return $resource; }