title: Laravel 4: Pass validation messages obtained from repository to controller
body: <p>Learning about Ioc and Repositories and stuck at last hurdle!</p>
  
  <p>Assuming I am validating input, how do I pass back messages from the Validator within the repository to the controller?</p>
  
  <p>UserRepository</p>
  
  <pre><code>interface UserRepository {
      public function all();
      public function create($input);
      public function findById($id);
  }
  </code></pre>
  
  <p>Sentry2UserRepository</p>
  
  <pre><code>class Sentry2UserRepository implements UserRepository {
  ...
  public function create($input) {
          $validation = Validator::make($input, User::$rules);
          if ($validation-&gt;passes()) {
      Sentry::createUser( array_except( $input, ['password_confirmation']));
  
              // Put something here to tell controller that user has been successfully been created
              return true;
          }
          else {
              // pass back to controller that validation has failed
              // with messages
              return $validation-&gt;messages(); ?????     
          }       
  ...
  </code></pre>
  
  <p>My UserController</p>
  
  <pre><code>UserController extends BaseController {
      ...
      public function postRegister() {
      $input['first_name'] = Input::get('first_name');
      $input['last_name'] = Input::get('last_name');
      $input['email'] = Input::get('email');
      $input['password'] = Input::get('password');
      $input['password_confirmation'] = Input::get('password_confirmation');
  
  
          // Something like
          if ($this-&gt;user-&gt;create($input)) {
              Session::flash('success', 'Successfully registered');
              return Redirect::to('/');
          }
          else {
              Session::flash('error', 'There were errors in your submission');
              return Redirect::to('user/login')-&gt;withErrors()-&gt;withInput();
          }
      }
      ...
  }
  </code></pre>
  
  <p>Only 1.5 weeks into Laravel so please go easy on me.</p>