使用 $request->json()->all()
使用这个方法获取的是前端请求头为Content-Type: application/json
传过来的值。使用 $request->input()
会在json无值是去获取query字段,不利于路由参数判断
参见:
vendor\laravel\framework\src\Illuminate\Http\Request.php
vendor\symfony\http-foundation\ParameterBag.php