Commit c432b7f5 authored by Taylor Otwell's avatar Taylor Otwell

Added Redirect->with_errors method.

parent bbc8a5d0
...@@ -90,6 +90,24 @@ class Redirect extends Response { ...@@ -90,6 +90,24 @@ class Redirect extends Response {
return $this; return $this;
} }
/**
* Flash a Validator's errors to the session data.
*
* This method allows you to conveniently pass validation errors back to views.
*
* <code>
* // Redirect and flash a validator's errors the session
* return Redirect::to('register')->with_errors($validator);
* </code>
*
* @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. * Magic Method to handle creation of redirects to named routes.
* *
...@@ -126,4 +144,4 @@ class Redirect extends Response { ...@@ -126,4 +144,4 @@ class Redirect extends Response {
throw new \BadMethodCallException("Method [$method] is not defined on the Redirect class."); throw new \BadMethodCallException("Method [$method] is not defined on the Redirect class.");
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment