How to add extra fields to a laravel 5 registration form

I have added extra field to registration form and validated that field.But I had issue while making migration after adding extra column though migration file to save extra field value in database.When I migrate it won’t do any thing.After this, I run migration with refresh option but it roll backed all tables data.And after exploring more I have found better solution to add extra column through following code.

 

Here you can achieve it through following steps.

1. Create new migration file using below command

 

2. Open newly created  migration file and add extra field column through up() and down() method

up() method:

down() method:

 

3. Run migration

After it a new column will be added in users table

5. To add extra form field, open \resources\views\auth\register.blade.php view file and add your form html

 

6. Validate extra field through auth controller RegisterController.php(\app\Http\Controllers\Auth)

 

 

7. Save extra field value to database through RegisterController.php(\app\Http\Controllers\Auth)

Also update the extra field to User.php model(\app\User.php)

 

Add a Comment

Your email address will not be published. Required fields are marked *