After Installation¶
Configuration Files¶
Laratrust now allows mutliple user models, so in order to configure it correctly, you must change the values inside the config/laratrust.php
file.
Multiple User Models¶
Inside the config/laratrust.php
file you will find an user_models
array, it contains the information about the multiple user models and the name of the relationships inside the Role
and Permission
models. For example:
'user_models' => [
'users' => 'App\User',
],
Note
The value of the key
inside the key => value
pair defines the name of the relationship inside the Role
and Permission
models.
It means that there is only one user model using Laratrust, and the relationship with the Role
and Permission
models is going to be called like this:
$role->users;
$role->users();
Note
Inside the role_user
and permission_user
table the user_type
column will be set with the user’s fully qualified class name, as the polymorphic relations describe it in Laravel docs.
So if you want to use the MorphMap feature just change the use_morph_map
value to true
inside Laratrust’s configuration file.
Automatic setup (Recommended)¶
If you want to let laratrust to setup by itselft, just run the following command:
php artisan laratrust:setup
This command will generate the migrations, create the Role
and Permission
models and will add the trait to the configured user models.
Note
The user trait will be added to the Model configured in the auth.php
file.
And then do not forget to run:
composer dump-autoload
Important
If you did the steps above you are done with the configuration, if not, please read and follow the whole configuration process