Search code examples
authenticationlaravel-5.3

Laravel 5.3 customizing registration form


I have setup default authentication that comes with laravel out of the box. Since that form requires from the user in order to registrate confirm password and name, which I would like to remove I wonder where can I remove those fields, since I can just remove them from the form, because then I get errors.

SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value (SQL: insert into users (email, password, updated_at, created_at) values ([email protected], $2y$10$rr8IQ5xwCJR8DuCXQbw/FenYrK/HcAtAk0br5OZF6ZSW2l21MxrsS, 2016-11-22 13:59:55, 2016-11-22 13:59:55))


Solution

  • Firstly, you will need to go your user migration database/migrations/2014_10_12_000000_create_users_table.php and either remove the name line or change it to be nullable i.e.

    $table->string('name')->nullable();
    

    Then go to App\Http\Controllers\Auth\RegisterController and you should be able to see a validator() method and a create() method. You will need to remove the name lines in each.

    Hope this helps!