From c432b7f55dbe7b3eac23a6d3dc78d8d4417dce09 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 23 Nov 2011 10:20:25 -0600 Subject: [PATCH] Added Redirect->with_errors method. --- laravel/redirect.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/laravel/redirect.php b/laravel/redirect.php index 80d855ef..2fdffa3f 100644 --- a/laravel/redirect.php +++ b/laravel/redirect.php @@ -90,6 +90,24 @@ public function with_input($filter = null, $items = array()) return $this; } + /** + * Flash a Validator's errors to the session data. + * + * This method allows you to conveniently pass validation errors back to views. + * + * + * // Redirect and flash a validator's errors the session + * return Redirect::to('register')->with_errors($validator); + * + * + * @param Validator $validator + * @return Redirect + */ + public function with_errors(Validator $validator) + { + return $this->with('errors', $validator->errors); + } + /** * Magic Method to handle creation of redirects to named routes. * @@ -126,4 +144,4 @@ public static function __callStatic($method, $parameters) throw new \BadMethodCallException("Method [$method] is not defined on the Redirect class."); } -} +} \ No newline at end of file