From 7463c522f9c7993a7d84eafe6217d96898098dc9 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Sep 2011 23:32:12 -0500 Subject: [PATCH] added comments for language class. --- laravel/input.php | 33 ++++++++++++++++++++++++++++++++- laravel/lang.php | 24 +++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/laravel/input.php b/laravel/input.php index a73cfafd..ff76e5c1 100644 --- a/laravel/input.php +++ b/laravel/input.php @@ -39,7 +39,7 @@ class Input { /** * Get all of the input data for the request. * - * This method returns a merged array containing $input->get() and $input->files(). + * This method returns a merged array containing Input::get() and Input::files(). * * @return array */ @@ -51,6 +51,8 @@ class Input { /** * Determine if the input data contains an item. * + * If the item is in the input array, but is an empty string, false will be returned. + * * @param string $key * @return bool */ @@ -64,6 +66,14 @@ class Input { * * This method should be used for all request methods (GET, POST, PUT, and DELETE). * + * + * // Get the "email" item from the input array + * $email = Input::get('email'); + * + * // Return a default value if the specified item doesn't exist + * $email = Input::get('name', 'Taylor'); + * + * * @param string $key * @param mixed $default * @return mixed @@ -87,6 +97,14 @@ class Input { /** * Get input data from the previous request. * + * + * // Get the "email" item from the old input + * $email = Input::old('email'); + * + * // Return a default value if the specified item doesn't exist + * $email = Input::old('name', 'Taylor'); + * + * * @param string $key * @param mixed $default * @return string @@ -106,6 +124,14 @@ class Input { /** * Get an item from the uploaded file data. * + * + * // Get the array of information for the "picture" upload + * $picture = Input::file('picture'); + * + * // Get a specific element from the file array + * $size = Input::file('picture.size'); + * + * * @param string $key * @param mixed $default * @return array @@ -120,6 +146,11 @@ class Input { * * This method is simply a convenient wrapper around move_uploaded_file. * + * + * // Move the "picture" item from the $_FILES array to a permanent location + * Input::upload('picture', 'path/to/storage/picture.jpg'); + * + * * @param string $key * @param string $path * @return bool diff --git a/laravel/lang.php b/laravel/lang.php index a9ee2021..e94eccd0 100644 --- a/laravel/lang.php +++ b/laravel/lang.php @@ -59,6 +59,14 @@ class Lang { /** * Create a new language line instance. * + * + * // Create a new language line instance for a given line + * $line = Lang::line('validation.required'); + * + * // Specify some replacements for the language line + * $line = Lang::line('validation.required', array('attribute' => 'email')); + * + * * @param string $key * @param array $replacements * @param string $language @@ -73,7 +81,21 @@ class Lang { } /** - * Get the language line. + * Get the language line as a string. + * + * If a language is specified, it should correspond to a directory within + * your application language directory. + * + * + * // Get a language line + * $line = Lang::line('validation.required')->get(); + * + * // Get a language line in a specified language + * $line = Lang::line('validation.required')->get('sp'); + * + * // Return a default value if the line doesn't exist + * $line = Lang::line('validation.required', null, 'Default'); + * * * @param string $language * @param string $default