all(), [ "parent" => "required|integer|min:0", "name" => "required|between:1,64", "description" => "max:255", "icon" => "max:255", "link_type" => "between:1,32", "link" => "max:255", ]); if ($validator->fails()) { return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors()); } $params = []; $params["parent"] = (int)$request->input("parent"); $params["name"] = $request->input("name"); $params["description"] = $request->input("description"); $params["icon"] = $request->input("icon"); $params["link_type"] = $request->input("link_type"); $params["link"] = $request->input("link"); $bar = new Models\ActionBar(); $result = $bar->AddActionBar($params); if ($result["code"] == 0) { return $this->success($result["data"]); } return $this->fail($result["code"], $this->error[$result["code"]]); } public function ModifyActionBar(Request $request) { $validator = Validator::make($request->all(), [ "id" => "required|integer|min:1", "parent" => "integer|min:0", "name" => "between:1,64", "description" => "max:255", "icon" => "max:255", "link_type" => "max:32", "link" => "max:255", ]); if ($validator->fails()) { return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors()); } $params = []; $params["id"] = $request->input("id"); $params["parent"] = $request->input("parent"); $params["name"] = $request->input("name"); $params["description"] = $request->input("description"); $params["icon"] = $request->input("icon"); $params["link_type"] = $request->input("link_type"); $params["link"] = $request->input("link"); $params["name"] = $request->input("name"); $bar = new Models\ActionBar(); $code = $bar->ModifyActionBar($params); return $this->response($code, $this->error[$code]); } public function DeleteActionBar(Request $request) { $validator = Validator::make($request->all(), [ "id" => "required|integer|min:1", ]); if ($validator->fails()) { return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors()); } $params = []; $bid = (int)$request->input("id"); $params["id"] = $bid; $bar = new Models\ActionBar(); $code = $bar->DeleteActionBar($params); return $this->response($code, $this->error[$code]); } /** * 管理员加载所有的菜单数据,根据层次返回数据给前端 * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function LoadActionBar(Request $request) { // $validator = Validator::make($request->all(), [ // "uid" => "required|integer|min:1", // ]); // if ($validator->fails()) { // return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors()); // } // $params = []; // $uid = $request->input("uid"); // $params["uid"] = $uid; $bar = new Models\ActionBar(); $result = $bar->LoadActionBarByIds_Format([], true); return $this->success($result); } }