Jonn's avatar
Level 1

Validation of login form

.....................

public function getLogin() { return view('login'); } public function postLogin() { $rules = array('username' =>'required','password' =>'required'); $validator = Validator::make(Input::all(), $rules); if($validator->fails()) { return Redirect::route('login')->withErrors($validator); } }

In the route file I have : Route::get('/login', array('as' => 'login', 'uses'=>'AuthController@getLogin')); Route::post('/login', array('uses' => 'AuthController@postLogin')); and then i have login view in resources/views/login The problem is, when i left login page fields blank and click submit, its displaying the following errors instead of redirecting back to it. Error Displayed: FatalErrorException in Handler.php line 25: Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in C:\xampp\htdocs\laravel\storage\framework\compiled.php on line 1703 and defined in C:\xampp\htdocs\laravel\app\Exceptions\Handler.php:25 Stack trace: #0 C:\xampp\htdocs\laravel\storage\framework\compiled.php(1703): App\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown

in Handler.php line 25
at HandleExceptions->fatalExceptionFromError(array('type' => '1', 'message' => 'Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in C:\xampp\htdocs\laravel\storage\framework\compiled.php on line 1703 and defined in C:\xampp\htdocs\laravel\app\Exceptions\Handler.php:25 Stack trace: #0 C:\xampp\htdocs\laravel\storage\framework\compiled.php(1703): App\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown', 'file' => 'C:\xampp\htdocs\laravel\app\Exceptions\Handler.php', 'line' => '25')) in compiled.php line 1721
at HandleExceptions->handleShutdown()

Can someone tell me where am going wrong? Am a beginner so if the error is a stupid one, am sorry but i can't figure it out. Am using laravel 5.0.35.

0 likes
0 replies

Please or to participate in this conversation.