Commit f6ea2676 authored by Taylor Otwell's avatar Taylor Otwell

Added Input::filled, Input::had, and Input::was_filled.

parent 92939a8a
...@@ -10,14 +10,39 @@ class Input { ...@@ -10,14 +10,39 @@ class Input {
public static $input; public static $input;
/** /**
* Determine if the input data contains an item. * Determine if the input data contains an item or set of items.
*
* @return bool
*/
public static function has()
{
foreach (func_get_args() as $key)
{
if (is_null(static::get($key)))
{
return false;
}
}
return true;
}
/**
* Determine if the input data contains an item or set of items that are not empty.
* *
* @param string $key
* @return bool * @return bool
*/ */
public static function has($key) public static function filled()
{ {
return ( ! is_null(static::get($key))); foreach (func_get_args() as $key)
{
if ( ! static::has($key) or trim((string) static::get($key)) == '')
{
return false;
}
}
return true;
} }
/** /**
...@@ -29,9 +54,6 @@ class Input { ...@@ -29,9 +54,6 @@ class Input {
*/ */
public static function get($key = null, $default = null) public static function get($key = null, $default = null)
{ {
// -----------------------------------------------------
// Has the input data been hydrated for the request?
// -----------------------------------------------------
if (is_null(static::$input)) if (is_null(static::$input))
{ {
static::hydrate(); static::hydrate();
...@@ -41,14 +63,39 @@ class Input { ...@@ -41,14 +63,39 @@ class Input {
} }
/** /**
* Determine if the old input data contains an item. * Determine if the old input data contains an item or set of items.
*
* @return bool
*/
public static function had()
{
foreach (func_get_args() as $key)
{
if (is_null(static::old($key)))
{
return false;
}
}
return true;
}
/**
* Determine if the old input data contains an item or set of items that are not empty.
* *
* @param string $key
* @return bool * @return bool
*/ */
public static function has_old($key) public static function was_filled()
{ {
return ( ! is_null(static::old($key))); foreach (func_get_args() as $key)
{
if ( ! static::had($key) or trim((string) static::old($key)) == '')
{
return false;
}
}
return true;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment