Table of Contents
In last tutorial we saw that how to setup Laravel authentication system of login, registration and password reset. Now in this tutorial I will describe on
how to add custom fields to a laravel registration form as a Freelance web developer it is most frequent task to do in any dynamic application . Different website have different signup pages that have lots of fields depending upon the project requirements.
As you can see in default Laravel it provide us with a default registration form. It just has the fields: Name, E-Mail Address, Password, and Confirm Password.
In most of the cases we require come custom fields like Phone Number, Address, Gender, Date of Birth, and so on.
Let's get started by customising the registration form with a new field.
One thing that i want to clear that I am not following Laravel migration way of adding,modifying database table's column. I am doing directly from phpmyadmin. protected $fillable = ; After saving the changes to the User model, you’re ready to register users with usernames. Visit here for complete project based advance level Laravel course. Contact us If you looking to hire experienced website designer and developer Delhi, India
Add a column 'username' inside 'users' table
Open your phpmyadmin , go to your Laravel database's table 'user' . Then add the column 'username'. I have choosen 'username' for a custom field example, you can choose anyone.Add form field 'username' as shown below inside register.blade.php
Of course, Laravel won’t automatically know what to do with this field, therefore you’ll need to make one last change.
Open the RegisterController.php controller found in app/Http/Controllers/Auth, and modify the validator method to look like this:
Next, scroll down and modify the create method to look like this:
Save these changes, and only one step remains. Open the app/User.php file and add the username field to the $fillable property like so: