- 响应设置
- return 数组
return response()->json([1, 2, 3]);
b. return 不想转换想直接返回出纯文本数据
return response()->view(‘index’,[‘id’=>10])
->header(‘Content-type’, ‘text/plain’);
return response(‘index‘)
->header(‘Content-type’, ‘text/plain’);
- 重定向
- 最简单使用
return redirect(‘浏览路径名’);
b. 方法二:
return redirect()->to(‘浏览器路径名’);
c. 方法三:传入路由名的方法
return redirect()->route(‘路由名’);
d. 方法四:返回到上一个路径
return redirect()->back();
e. 方法五:不管怎么跳转一定是跳转到away里面的路径
return redirect()->away(‘http://www.baidu.com‘);