$serverService->getAllServers() ]); } public function sort(Request $request) { ini_set('post_max_size', '1m'); $params = $request->only( 'shadowsocks', 'vmess', 'trojan', 'hysteria', 'vless' ) ?? []; try{ DB::beginTransaction(); foreach ($params as $k => $v) { $model = 'App\\Models\\Server' . ucfirst($k); foreach($v as $id => $sort) { if (!$model::find($id)->update(['sort' => $sort])) { throw new ApiException(500, '保存失败'); } } } DB::commit(); }catch (\Exception $e){ DB::rollBack(); throw $e; } return $this->success(true); } }