简体   繁体   English

$request->only() 在 laravel 7.9 中返回空数组

[英]$request->only() return empty array in laravel 7.9

I have a mess while laravel 5.4 to 7.9, I have read the follow document: https://laravel.com/docs/7.x/requests , but I am not clear in my case:我在 laravel 5.4 到 7.9 时一团糟,我已阅读以下文档: https://laravel.com/docs/7.x/requests ,但我不清楚我的情况:

在此处输入图像描述

In laravel 5.4, it returns an array:在 laravel 5.4 中,它返回一个数组:

拉拉维尔 5.4

It's an emty array in laravel 7.9:它是 laravel 7.9 中的一个空数组:

在此处输入图像描述

Thanks!谢谢!

The problem you are describing is expected behaviour and was changed in between versions.您描述的问题是预期的行为,并且在版本之间进行了更改。

Documentation from Laravel 5.4 Reference Laravel 5.4参考文档

The only method returns all of the key / value pairs that you request, even if the key is not present on the incoming request. only的方法返回您请求的所有键/值对,即使传入请求中不存在该键。 When the key is not present on the request, the value will be null .当请求中不存在密钥时,该值将为null

Documentation from Laravel 7.9 Reference Laravel 7.9参考文档

The only method returns all of the key / value pairs that you request; only的方法返回您请求的所有键/值对; however, it will not return key / value pairs that are not present on the request.但是,它不会返回请求中不存在的键/值对。

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

相关问题 Laravel 数组 $request->all() 为空 - Laravel array $request->all() empty return $request->post(); 是什么意思? 在 laravel 中? - What is the meaning of return $request->post(); in laravel? $ request-> file返回null-Laravel - $request->file return null - Laravel return $request->input() 在 laravel 上没有返回任何内容 - return $request->input() is returning nothing on laravel Laravel:$ request-> all()使用json xhr调用时给出空数组 - Laravel: $request->all() gives empty array when called with json xhr dd($request->all()) 通过 ajax laravel 上传文件时的空数组 - Empty array when dd($request->all()) upload file via ajax laravel 使用 PUT 方法 AJAX 导致 Laravel 中的 $request->all() 数组为空 6 - Using PUT method AJAX results in empty $request->all() array in Laravel 6 从phpunit调用时,laravel中的$ request-> all()返回空 - $request->all() in laravel returns empty when called from phpunit Laravel $request->all() 使用 multipart/form-data 为空 - Laravel $request->all() is empty using multipart/form-data Laravel:当我使用$ request-> all()但在fill($ request-> only('...')中工作时,fill()和update()不起作用 - Laravel : fill() and update() not work when i use $request->all() but work in fill($request->only('…'))
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM