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

Signed-off-by: Colin Viebrock <colin@viebrock.ca>
This commit is contained in:
Colin Viebrock
2012-05-09 15:51:16 -05:00
parent be5eaf946c
commit 319c450f6f
2 changed files with 27 additions and 3 deletions

View File

@@ -245,6 +245,30 @@ function array_pluck($array, $key)
}, $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.
*