# Upgrade from 4.0 to 5.0
IMPORTANT
Laratrust 5.0 requires Laravel >= 5.2.32.
In order to upgrade from Laratrust 4.0 to 5.0 you have to follow these steps:
- Change your
composer.jsonto require the 5.0 version of Laratrust:
"santigarcor/laratrust": "5.0.*"
Run
composer updateto update the source code.Run
php artisan config:clearandphp artisan cache: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.4.5. Set the
middleware.registervalue tofalse.4.6. Set the
teams_strict_checkvalue totrueonly if you are using teams.Inside your
Role,PermissionandTeammodels update theusestatement from:use Laratrust\LaratrustRoletouse Laratrust\Models\LaratrustRole;use Laratrust\LaratrustPermissiontouse Laratrust\Models\LaratrustPermission;use Laratrust\LaratrustTeamtouse Laratrust\Models\LaratrustTeam;
If you use the ability method and you pass it comma separated roles or permissions, change them to a pipe separated string:
// From
$user->ability('admin,owner', 'create-post,edit-user');
// To
$user->ability('admin|owner', 'create-post|edit-user');
- If you are using the
Ownableinterface, please update all the classes implementing it:
// From
public function ownerKey() {}
// To
public function ownerKey($owner) {}
If you use teams and in your code you use the
syncRolesandsyncPermissionsread the new sync method behavior.The
cachedRolesandcachedPermissionsmethods now return an array when you have thelaratrust.use_cacheoption set totrue. So if you use these methods, please check your code.Delete the
LaratrustSeeder.phpfile and runphp artisan laratrust:seeder.Run
composer dump-autoload.
Now you can use the 5.0 version without any problem.