apurva kinkar
apurva kinkar

Reputation: 21

laravel validation syntax error

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('/');

        }

    }


}

Upvotes: 2

Views: 973

Answers (2)

user2110253
user2110253

Reputation: 315

Missing semicolon in log::error($validator)

Upvotes: 0

Sougata Bose
Sougata Bose

Reputation: 31749

Missing ; -

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

    } else {

Small change.

log::error($validator); won't be executed as the action will return before it reaches the log::error(). So it should be -

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

Upvotes: 4

Related Questions