2
votes

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

my own custom form

1
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.Sandeesh
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.4Sandeesh
Thanks a lot ! I copy/pasted postLogin, postEmail and postReset methods to authcontroller.php and passwordcontroller.php and got the error messages as desired. Now, I think I don't have to worry about 'required' validation error. And, as u suggested, I am planning to use laravel 5.4. But i have doubt that whether it will work with php 5.5.3 ! Because at first, I had installed laravel 5.4 but i think i got some like plugins or security won't work with this php version messages. Then i installed laravel 5.0 without trying laravel 5.4. Thank you !Anoj Hang Yamphu
I've added the comment as my answer along with the php version information. This should give you a clear idea of what you can start with. Also the next version 5.5 will be PHP 7 only. So i would suggest go with laravel 5.4 for learning and install PHP 7.Sandeesh

1 Answers

0
votes

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/Authent‌​icatesAndRegistersUs‌​ers.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