public static function bootLaratrustRoleTrait()
{
$flushCache = function ($role) {
$role->flushCache();
return true;
};
// If the role doesn't use SoftDeletes
if (method_exists(Config::get('laratrust.role'), 'restored')) {
static::restored($flushCache);
}
static::deleted($flushCache);
static::saved($flushCache);
static::deleting(function ($role) {
if (!method_exists(Config::get('laratrust.role'), 'bootSoftDeletes')) {
$role->users()->sync([]);
$role->permissions()->sync([]);
}
});
}