diff --git a/laravel/input.php b/laravel/input.php index f8785711..e949184f 100644 --- a/laravel/input.php +++ b/laravel/input.php @@ -16,7 +16,7 @@ class Input { */ public static function all() { - $input = array_merge(static::get(), static::query(), $_FILES); + $input = array_merge(static::get(), static::query(), static::file()); unset($input[Request::spoofer]); @@ -55,7 +55,14 @@ public static function has($key) */ public static function get($key = null, $default = null) { - return array_get(Request::foundation()->request->all(), $key, $default); + $value = Request::foundation()->request->get($key); + + if (is_null($value)) + { + return array_get(static::query(), $key, $default); + } + + return $value; } /** @@ -161,7 +168,29 @@ public static function old($key = null, $default = null) */ public static function file($key = null, $default = null) { - return array_get(Request::foundation()->files->all(), $key, $default); + return array_get($_FILES, $key, $default); + } + + /** + * Move an uploaded file to permanent storage. + * + * This method is simply a convenient wrapper around move_uploaded_file. + * + * + * // Move the "picture" file to a new permanent location on disk + * Input::upload('picture', 'path/to/photos', 'picture.jpg'); + * + * + * @param string $key + * @param string $directory + * @param string $name + * @return bool + */ + public static function upload($key, $directory, $name = null) + { + if (is_null(static::file($key))) return false; + + return Request::foundation()->files->get($key)->move($directory, $name); } /** diff --git a/laravel/paginator.php b/laravel/paginator.php index 854b0e37..ceffbe85 100644 --- a/laravel/paginator.php +++ b/laravel/paginator.php @@ -112,7 +112,7 @@ public static function make($results, $total, $per_page) */ public static function page($total, $per_page) { - $page = Input::query('page', 1); + $page = Input::get('page', 1); // The page will be validated and adjusted if it is less than one or greater // than the last page. For example, if the current page is not an integer or