Laratrust\Traits\LaratrustRoleTrait::bootLaratrustRoleTrait PHP Method

bootLaratrustRoleTrait() public static method

Boot the role model Attach event listener to remove the many-to-many records when trying to delete Will NOT delete any records if the role model uses soft deletes.
public static bootLaratrustRoleTrait ( ) : void | boolean
return void | boolean
    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([]);
            }
        });
    }