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?
-
You can write a migration to add those fields as nullable terms. And let user fill them later after registrationVishal Sharma– Vishal Sharma2015-12-17 01:51:25 +00:00Commented Dec 17, 2015 at 1:51
-
@VishalSh So I would modify the user model in order to include these and set these through queries?mattrick– mattrick2015-12-17 02:02:15 +00:00Commented Dec 17, 2015 at 2:02
Add a comment
|
1 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.