php - laravel 验证语法错误

标签 php laravel laravel-validation

Stack trace: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'syntax error, unexpected '}'' in 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('/');

        }

    }


}

最佳答案

缺少; -

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

    } else {

小变化。

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

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

关于php - laravel 验证语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36443749/

相关文章:

laravel - 如何为 laravel 验证器的自定义存在规则添加连接?

php - Laravel 检查更新中没有自身的唯一规则

php - 将我的网站 Logo 添加到 Google 结账页面

php - 单个 Route::get() 中的多个路由调用 Laravel 4

php - Laravel:表单文件上传失败 - 检测到不正确的类型

php - Elasticquent(ElasticSearch)Laravel限制

angularjs - Laravel 5 使用现有的 AngularJS 验证

php - MYSQL/PHP : Possible to Join on One to Many Field?

php - PHP 中的词性标注器?

laravel - 使用 Passport Password Grants 和/或 Guzzle 时服务器卡住