[Bug] Http\Request::only(), ::except(), and ::get() pull from ::input(), rather than ::all()
I'm not sure if this should be considered a "bug", per se, but it seems to me that since Input::all() can retrieve files, then why shouldn't Input::only(), Input::except(), and Input::get() be able to as well?
This can be fixed by updating the following methods accordingly.
/**
* Get a subset of the items from the input data.
*
* @param array $keys
* @return array
*/
public function only($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
return array_only($this->all(), $keys) + array_fill_keys($keys, null); // Updated from ->input()
}
/**
* Get all of the input except for a specified array of items.
*
* @param array $keys
* @return array
*/
public function except($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
$results = $this->all(); // Updated from ->input()
foreach ($keys as $key) array_forget($results, $key);
return $results;
}
It seems as though the get() method is defined on the parent class, which could be overridden, but that may or may not be necessary. I think the big need here is with the only() and except() methods.
My particular use case is that I'm trying to do something like this...
$input = Input::only('bla', 'bla', 'blocks');
// later...
foreach($input['blocks'] as $id => $attributes)
// do stuff for each block, some of which only contain files (images)
I was able to override this functionality using the instructions outlined here, however I'd still like for this Issue to remain open for discussion.
Input::get() would not benefit from this as Input::file() already does the purpose of retrieving a singular file input. Input::only() and Input::except() may benefit to return similar to Input::all() with a reduced set.
@riotCode Yes, I agree. It's more useful for the collections. However, if you're trying to fetch an array with Input::get(), and said array is expected to have either strings and/or files, it can get complicated here as well.
Done for only and except.