Customize Laravel Registration Form With Additional Fields

Aman Dhiman
Jun 1, 2019 · 4 min read
Image for post
Image for post

Hey Guys! This is Aman. Hope you all are doing well. Hope you all read my last blog which was of the Laravel Authorization. In that blog, we learned how to work with Laravel Auth package and how to make Login, Registration, Forgot Password, etc. Now, Let’s continue with the Laravel Auth and proceed further with the registration form customization with additional fields.

As you have seen the default registration form Laravel provides us in my last blog. It just has Name, E-Mail Address, Password and Confirm Password.

Sometimes we required some other fields in the form like Phone Number, Address, Gender, Date of Birth and so on.

Let’s start the development with the registration form customization with a new field. I am going to create Phone Number.

Step 1: First make a migration to create a new field in the database table. Command will be like.

Image for post
Image for post

Now, you can see in the database->migrations we have a newly migrated migration file.

Image for post
Image for post

Step 2: Open the file in the editor and modify the up() and down() functions. It will look like this.

Image for post
Image for post

Step 3: After that, run the migration by following the command.

Image for post
Image for post

This migration will create a new field in the database.

Image for post
Image for post

Step 4: Go to resources/auth/register.blade.php and edit the registration form by adding the below HTML code.

Tada!! We can see a new field in the registration form.

Image for post
Image for post

Step 5: Oh my God! Another step 🙄. Yes, it is required. Because it will save the phone number in the database. Don’t worry it is not that difficult 😁

Open RegisterController.php controller found in app/Http/Controllers/Auth, and modify the validator. It will look like this.

After this, scroll down in the same file and modify the create function. It will look like

Step 6: This is the final step. Save the RegisterController.php file open app/User.php and add ‘phone’ field in the $fillable property and save the file.

That’s it. Now, test the registration form you can see the saved number field in the database.

Image for post
Image for post

Yeah!!! It is done. Well done 👍 Now, enjoy the work you have done and follow the same steps if you need more fields in the form.

Try these steps and make the Customization working in your Laravel application form 😎👍

I created one sample Laravel application. You can visit my repo and fork it or clone the code from my repo and start work further. Click here to visit my GitHub repo.

This is all about Customize Laravel Registration Form With Additional Fields. If you found this article useful please clap 👏 for this article.

Have a happy coding! 🤗

ZestGeek

ZestGeek Solution is a leading IT company that provide high…

Aman Dhiman

Written by

I am PHP developer. Currently, I am working with ZestGeek Solutions. I just started write blogs on Medium.

ZestGeek

ZestGeek

ZestGeek Solution is a leading IT company that provide high quality and enterprise level solutions across wide range of platforms and technologies.

Aman Dhiman

Written by

I am PHP developer. Currently, I am working with ZestGeek Solutions. I just started write blogs on Medium.

ZestGeek

ZestGeek

ZestGeek Solution is a leading IT company that provide high quality and enterprise level solutions across wide range of platforms and technologies.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store