# Upgrade from 7.x to 8.x
IMPORTANT
Laratrust 8.x requires Laravel 10.x
In order to upgrade from Laratrust 7.x to 8.x you have to follow these steps:
- Change your
composer.jsonto require the 8.x version of Laratrust:
"santigarcor/laratrust": "^8.0"
Run
composer updateto update the source code.Run
php artisan config:clear,php artisan cache:clearandphp artisan view:clear.Update your
config/laratrust.php:4.1. Backup your
config/laratrust.phpconfiguration values.4.2. Delete the
config/laratrust.phpfile.4.3. Run
php artisan vendor:publish --tag=laratrust.4.4. Update the
config/laratrust.phpfile with your old values.The ownership feature has been completely removed. Then migrate that code.
The methods
isAandisAnhave been removed, replace withhasRole.The user model now must implement the
Laratrust\Contracts\LaratrustUserinterface and use theLaratrust\Traits\HasRolesAndPermissionstrait.The
Role,PermissionandTeammodels should inherit now from the following classes:
| Old | New |
|---|---|
Laratrust\Models\LaratrustRole | Laratrust\Models\Role |
Laratrust\Models\LaratrustPermission | Laratrust\Models\Permission |
Laratrust\Models\LaratrustTeam | Laratrust\Models\Team |
- The methods signatures have been changed. Follow this table to migrate them.
| Old | New |
|---|---|
attachPermission | givePermission |
attachPermissions | givePermissions |
detachPermission | removePermission |
detachPermissions | removePermissions |
attachRole | addRole |
detachRole | removeRole |
- The methods signatures for the events have been changed. Follow this table to migrate them.
| Old | New |
|---|---|
roleAttached | roleAdded |
roleDetached | roleRemoved |
permissionAttached | permissionAdded |
permissionDetached | permissionRemoved |
- The Querying relation signatures have been changed. Follow this table to migrate them.
| Old | New |
|---|---|
whereRoleIs | whereHasRole |
orWhereRoleIs | orWhereHasRole |
wherePermissionIs | whereHasPermission |
orWherePermissionIs | orWhereHasPermission |
whereDoesntHaveRole | whereDoesntHaveRoles |
Now you can use the 8.x version without any problem.