![](/img/trans.png)
[英]Unable to exclude null values from array of objects in Laravel Form Request Validation?
[英]Exclude Laravel-specific values from request
我想在提交表單后運行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
是的,Request類提供了
$request->except('_method', '_token')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.