How to add custom fields to registration form in Laravel

In this tutorial, you can study how to add custom field to Laravel. First you have to install Laravel in your computer and then install the Auth

You can follow the steps given below to add custom field to registration post

Create new Laravel project

Download the Laravel via composer

Create new Laravel project named custom

Generate the Authentication scaffolding which has the all authentication related controllers, models and view. This will create table users in the database to hold user information

When you install the Laravel and Auth scaffolding you can start the web server by executing the following artisan command

This will start the Webserver and you can see the app at http://127.0.0.1:8000

Add Custom field to register page

Register page is located at resources\views\auth\register.blade.php. I am going to add filed to enter Phone

You can add the following code below the Email field

Now you can see the register page at http://127.0.0.1:8000/register

Add field to table

All the user information is stored in the users table in the database so we need to add phone field to users table

I will create migration file to add field to users table

I will add the following code to the database migration file created

Next you can run the migrate command to add field to the table

Add code to RegisterController

Finally you can add the code to create method of the RegisterController located at App\Http\Controllers\Auth