laravel验证语法错误

时间:2016-04-06 07:01:54

标签: php laravel laravel-validation

  

堆栈跟踪:异常'Symfony \ Component \ Debug \ Exception \ FatalErrorException',消息'语法错误,意外'}''在D:\ xampp \ htdocs \ guestlara \ app \ controllers \ LoginController.php:23

public function login_user()
{

    $rules = array(
                    'email'=> 'Required|Between:3,64|Email|Unique:users',
                    'password'=>'Required|AlphaNum|Between:4,8|Confirmed',
                    );
    $validator = Validator::make(Input::all(), $rules);

    if ($validator->fails()) {

        // get the error messages from the validator
        $messages = $validator->messages();

        // redirect our user back to the form with the errors from the validator
        return Redirect::to('/')
        ->withErrors($validator);
        log::error($validator)

    } 
    else 
    {

        // attempt to do the login
        if (Auth::attempt($users)) {

            return Redirect::to('dashboard');

        } else {        

            return Redirect::to('/');

        }

    }


}

2 个答案:

答案 0 :(得分:4)

缺少; -

        return Redirect::to('/')
               ->withErrors($validator);
        log::error($validator); // Here

    } else {

小变化。

log::error($validator);将不会被执行,因为操作将return到达log::error()之前。所以它应该是 -

log::error($validator);
return Redirect::to('/')
       ->withErrors($validator);

答案 1 :(得分:0)

在log :: error($ validator)中缺少分号