我要跑 json_encode($request->all())
提交表单后,返回的数组被 _method
“污染”和 _token
值。
有没有什么巧妙的方法可以从生成的 json 中排除特定于框架的字段?
最佳答案
$request->only('username', 'password');
或者
$request->except('_method', '_token');
来源:
https://laravel.com/api/5.3/Illuminate/Http/Request.html#method_only
关于php - 从请求中排除 Laravel 特定的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38664845/