简体   繁体   中英

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.

Is there any neat way to exclude the framework-specific fields from the generated json?

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

or

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

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

是的,Request类提供了

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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