withSuccess($message .'成功!'); case 'failed' : return redirect($path) ->withErrors($message.'失败!'); case 'error' : return redirect($path)->withErrors("找不到该记录!"); default : break; } } /** * 接口返回成功 JSON格式 * @param string $message 提示信息 * @param array $data 返回数据 * @return \Illuminate\Http\JsonResponse */ public function successJson($message = '成功', $data = []) { return response()->json([ 'result' => 1, 'msg' => $message, 'data' => $data ], 200, ['charset' => 'utf-8']); } /** * 接口返回错误JSON 格式 * @param string $message 提示信息 * @param array $data 返回数据 * @return \Illuminate\Http\JsonResponse */ public function errorJson($message = '失败', $data = []) { return response()->json([ 'result' => 0, 'msg' => $message, 'data' => $data ], 200, ['charset' => 'utf-8']); } }