2016-04-06 266 views
2

在D:\ xampp \ htdocs \ guestlara \ app \ controllers \ LoginController中堆棧跟蹤:異常'Symfony \ Component \ Debug \ Exception \ FatalErrorException'消息'syntax error,unexpected'}' .PHP:23laravel驗證語法錯誤

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

     } 

    } 


} 
+0

這是PHP語言的語法錯誤。這與Laravel及其驗證都沒有共同之處。 – Rolice

回答

4

缺少; -

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

    } else { 

小的變化。

log::error($validator);將不會執行,因爲該操作將在達到log::error()之前執行。因此,它應該是 - 在日誌

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

缺少分號::錯誤($驗證)

+0

爲什麼有人會downvote這個答案? – Rolice