简体   繁体   English

从请求中排除Laravel特定的值

[英]Exclude Laravel-specific values from request

I want to run json_encode($request->all()) after a form is submitted, however the returned array is "polluted" with _method and _token values. 我想在提交表单后运行json_encode($request->all()) ,但是返回的数组被_method_token值“污染”。

Is there any neat way to exclude the framework-specific fields from the generated json? 有什么巧妙的方法可以从生成的json中排除特定于框架的字段?

$request->only('username', 'password');

or 要么

$request->except('_method', '_token');

Source: https://laravel.com/api/5.3/Illuminate/Http/Request.html#method_only 来源: https : //laravel.com/api/5.3/Illuminate/Http/Request.html#method_only

是的,Request类提供了

$request->except('_method', '_token')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM