According to this answer https://stackoverflow.com/a/29740218/7921383 handling Boolean values in URL is depend on framework.
How to pass Boolean values false
and true
in laravel?
According to this answer https://stackoverflow.com/a/29740218/7921383 handling Boolean values in URL is depend on framework.
How to pass Boolean values false
and true
in laravel?
Since version laravel/framework: v6.13.
There are added ability to call on the \Illuminate\Http\Request
method boolean
that will return true when value is "1", "true", "on", and "yes". Otherwise, returns false.
You can try this way:
http://some-url?arg=true
Or
http://some-url?arg=false
And in php:
$boolean = filter_var( $request->query('arg'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE );
There is a helper in laravel
Request::boolean('query-param-name')
At the end it does same thing as Dimitri Leiko described, but maybe helps other people.
public function boolean($key = null, $default = false)
{
return filter_var($this->input($key, $default), FILTER_VALIDATE_BOOLEAN);
}