简体   繁体   中英

$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:

在此处输入图像描述

In laravel 5.4, it returns an array:

拉拉维尔 5.4

It's an emty array in laravel 7.9:

在此处输入图像描述

Thanks!

The problem you are describing is expected behaviour and was changed in between versions.

Documentation from Laravel 5.4 Reference

The only method returns all of the key / value pairs that you request, even if the key is not present on the incoming request. When the key is not present on the request, the value will be null .

Documentation from Laravel 7.9 Reference

The only method returns all of the key / value pairs that you request; however, it will not return key / value pairs that are not present on the request.

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