Ad

Laravel - Custom User Fields

- 1 answer

I want to add custom user fields, but not have them be assigned at registration or "required". Would the most effective way to do this be adding a field to the Auth object, or would there be a better way to do this?

Ad

Answer

In a fresh Laravel 5 installation you have to edit the User class and the users migration:

1) In your app/User.php you have to extend the $fillable array for each custom field.

Example: $fillable = ['name', 'email', 'password', 'city']; for a custom city field.

2) In your database/migrations/2014_10_12_000000_create_users_table.php you have to add a database column for each custom field and run afterwards php artisan migrate (see http://laravel.com/docs/master/migrations).

Example: $table->string('city'); for a custom city field.

Ad
source: stackoverflow.com
Ad