all(), [ 'name' => 'required|string|unique:ss_config,name', 'type' => 'required|numeric|between:1,3', ]); if ($validator->fails()) { return Response::json(['status' => 'fail', 'message' => $validator->errors()->all()]); } if (SsConfig::create($validator->validated())) { return Response::json(['status' => 'success', 'message' => trans('common.success_item', ['attribute' => trans('common.add')])]); } return Response::json(['status' => 'fail', 'message' => trans('common.failed_item', ['attribute' => trans('common.add')])]); } // 设置SS默认配置 public function update(SsConfig $ss): JsonResponse { if ($ss->setDefault()) { return Response::json(['status' => 'success', 'message' => trans('common.success_item', ['attribute' => trans('common.edit')])]); } return Response::json(['status' => 'fail', 'message' => trans('common.failed_item', ['attribute' => trans('common.edit')])]); } // 删除SS配置 public function destroy(SsConfig $ss): JsonResponse { try { if ($ss->delete()) { return Response::json(['status' => 'success', 'message' => trans('common.success_item', ['attribute' => trans('common.delete')])]); } } catch (Exception $e) { Log::error(trans('common.error_action_item', ['action' => trans('common.delete'), 'attribute' => trans('user.node.info')]).': '.$e->getMessage()); return Response::json(['status' => 'fail', 'message' => trans('common.failed_item', ['attribute' => trans('common.delete')]).', '.$e->getMessage()]); } return Response::json(['status' => 'fail', 'message' => trans('common.failed_item', ['attribute' => trans('common.delete')])]); } }