I've pulled in cartalyst/sentinel and i've run the migrations required to generate the tables
php artisan migrate --package=cartalyst/sentinel
I notice that these are the columns available in the users table
- id
- password
- permissions
- last_login
- first_name
- last_name
- created_at
- updated_at
I'd like to add username after the email. So i created a migration file that does that.
//add a column username after email in the users table
$table->string('username')->after('email')->unique();
Now when i use Sentinel::register
$credentials = Input::all();
$user = Sentinel::register($credentials);
The username doesn't get saved in the table. So i've managed to get it fillable by editing vendor/cartalyst/sentinel/src/Users/EloquentUser.php
protected $fillable = [
'email',
'username', /* i added this */
'password',
'last_name',
'first_name',
'permissions',
];
Now this works, the username gets stored in the table. But im wondering if what i'm doing is right? Should we not touch the files in the packages folder. How do we solve this?
In Laravel 5.2 , after doing @Antonio steps , you need to run
php artisan config:cache
instead ofphp artisan config:publish cartalyst/sentinel
Almost. You have to create your own User clas, extending
vendor/cartalyst/sentinel/src/Users/EloquentUser.php
:Publish Sentinel's config:
And in the config file, set the user model to your own: