Yada
Yada

Reputation: 31225

Laravel checking input isset

Laravel Input helper has

Input::has('debug')

My problem is that I often use query parameter without the value such has http://example.com?debug

The problem is that Input::has('debug') will return false in this case because there is no value. ie. debug=1

So I end up having to use isset($_GET['debug']).

Is there a laravel way to check whether the input isset?

Upvotes: 4

Views: 11741

Answers (1)

Razor
Razor

Reputation: 9835

In this case, use exists method:

// http://example.com?debug
var_dump(app('request')->exists('debug')); // return true

// http://example.com
var_dump(app('request')->exists('debug')); // return false

Upvotes: 16

Related Questions