Php getErrors和getInput

Php getErrors和getInput,php,laravel,Php,Laravel,我只想在表单验证失败的情况下添加getErrors和getInput。我想知道如何将其添加到重定向变量中 /** * Store a newly created user in storage. * * @return Response */ public function store() { $input = Input::all(); $message = 'The form failed to validate.'; $redirect = Redirect

我只想在表单验证失败的情况下添加getErrors和getInput。我想知道如何将其添加到重定向变量中

/**
 * Store a newly created user in storage.
 *
 * @return Response
 */
public function store()
{
    $input = Input::all();
    $message = 'The form failed to validate.';
    $redirect = Redirect::to('users/create');

    $validation = Validator::make($input, $rules);

    if ($validation->fails())
    {
        $message = 'The form failed to validate';

        // add on ->getErrors()->getInput();
    }

    User::create([
        'username' => $input['username'],
        'email_address' => $input['email_address'],
        'password' => $input['password'],
        'role_id' => $input['role']

    ]);

    return $redirect->with('message', $message);
}
if ($validation->fails())
{
    $message = 'The form failed to validate';

    $redirect->withErrors($validation)->withInput();
}