Quantcast
Viewing all articles
Browse latest Browse all 54

Answer by totymedli for Request::has() returns false even when parameter is present

tl;dr

Upgrade to Laravel 5.5 or higher. They changed this so now it works as you originally expected.

Explanation

In the Laravel 5.5 upgrade guide, we read the following:

The has Method

The $request->has() method will now return true even if the input value is an empty string or null. A new $request->filled() method has been added that provides the previous behaviour of the has() method.

The $request->exists() method still works, it is just an alias for $request->has().

Examining the source code

If you click to the commands above, you can check out the source code and see that they literally just renamed exists to has, has to filled, then aliased exists to has.


Viewing all articles
Browse latest Browse all 54

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>