Laravel检查输入isset


Laravel checking input isset

Laravel输入助手具有

输入::具有("调试")

我的问题是,我经常使用没有值的查询参数http://example.com?debug

问题是,在这种情况下,Input::has('debug')将返回false,因为没有值。即调试=1

所以我最终不得不使用isset($_GET['debug'])

有没有一种更简单的方法来检查输入是否正确?

在这种情况下,使用exists方法:

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