Commit 319c450f authored by Colin Viebrock's avatar Colin Viebrock

Make Input::only() and Input::except() into array_only() and array_except() helpers.

Signed-off-by: 's avatarColin Viebrock <colin@viebrock.ca>
parent be5eaf94
...@@ -245,6 +245,30 @@ function array_pluck($array, $key) ...@@ -245,6 +245,30 @@ function array_pluck($array, $key)
}, $array); }, $array);
} }
/**
* Get a subset of the items from the given array.
*
* @param array $array
* @param array $keys
* @return array
*/
function array_only($array, $keys)
{
return array_intersect_key( $array, array_flip((array) $keys) );
}
/**
* Get all of the given array except for a specified array of items.
*
* @param array $array
* @param array $keys
* @return array
*/
function array_except($array, $keys)
{
return array_diff_key( $array, array_flip((array) $keys) );
}
/** /**
* Transform Eloquent models to a JSON object. * Transform Eloquent models to a JSON object.
* *
......
...@@ -127,7 +127,7 @@ class Input { ...@@ -127,7 +127,7 @@ class Input {
*/ */
public static function only($keys) public static function only($keys)
{ {
return array_intersect_key(static::get(), array_flip((array) $keys)); return array_only(static::get(), $keys);
} }
/** /**
...@@ -146,7 +146,7 @@ class Input { ...@@ -146,7 +146,7 @@ class Input {
*/ */
public static function except($keys) public static function except($keys)
{ {
return array_diff_key(static::get(), array_flip((array) $keys)); return array_except(static::get(), $keys);
} }
/** /**
......
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