Hello I am new to laravel. I am using 5.0v. I have learnt a little to play with welcome page of laravel, Controllers, models, routes and database. So, what i did is that I used laravel login page in place of welcome page. when i didn't enter anything in email and password field, i got validaton eror: The email field is required. and The password field is required. After that i tried with password reset page and register page.I got correct validation errors. For Register page, I removed 'required' from rules section from services>registrar.php file. And as expected, i didnt get 'required' validation error for register page. But I am still getting 'required' error for login and password reset page. I deleted the email and password fields from login.blade.php. But, when i click login, it shows 'required' error for both email and password fields though the fields are not there on the page. Then, i created a new page with form fields other than email and password type. I used that in place of login page. But when leave the fields empty and click submit, it shows 'required' error for email and password i.e. "The email field is required." and "The password field is required". So, what is the cause of this problem? And, like i edited registrar.php for validation error rules, is there a way to edit for login and password reset page? when other fields are there
1 Answers
Hi that's a good question with eagerness to explore the framework. The answer is that in laravel 5.0, the validation of the login is embedded deep into the controller logic by the framework and changing it is not so trivial. With the newer versions of the framework, you can do this with much more ease. In laravel 5.0 the validation for login is hard coded in the method 'postLogin' in the file veondor/laravel/framework/Illuminate/Foundation/Auth/AuthenticatesAndRegistersUsers.php
. If you really need to change this then you could copy paste this whole method into app/Http/Controllers/Auth/AuthController.php
. Therefore overwriting the built in method with this one. And now you can make your desired changes in this 'postLogin' method in 'AuthController'. Hope this helps. If you're still in the learning phase then i would suggest you to start with version 5.3 or 5.4
Laravel PHP requirement
Laravel 5.4 : PHP >= 5.6.4
Laravel 5.3 : PHP >= 5.6.4
Laravel 5.2 : PHP >= 5.5.9
Laravel 5.1 : PHP >= 5.5.9
Laravel 5.0 : PHP >= 5.4, PHP < 7
veondor/laravel/framework/Illuminate/Foundation/Auth/AuthenticatesAndRegistersUsers.php
. – Sandeeshapp/Http/Controllers/Auth/AuthController.php
. Therefore overwriting the built in method with this one. And now you can make your desired changes in this 'postLogin' method in 'AuthController'. Hope this helps. If you're still in the learning phase then i would suggest you to start with version 5.3 or 5.4 – Sandeesh