src/Traits/LaratrustUserTrait.php
public static function bootLaratrustUserTrait()
    {
        $flushCache = function ($user) {
            $user->flushCache();
        };

        // If the user doesn't use SoftDeletes.
        if (method_exists(static::class, 'restored')) {
            static::restored($flushCache);
        }

        static::deleted($flushCache);
        static::saved($flushCache);

        static::deleting(function ($user) {
            if (method_exists($user, 'bootSoftDeletes') && !$user->forceDeleting) {
                return;
            }

            $user->roles()->sync([]);
            $user->permissions()->sync([]);
        });
    }
public static function bootLaratrustUserTrait()
    {
        $flushCache = function ($user) {
            $user->flushCache();
        };

        // If the user doesn't use SoftDeletes.
        if (method_exists(static::class, 'restored')) {
            static::restored($flushCache);
        }

        static::deleted($flushCache);
        static::saved($flushCache);

        static::deleting(function ($user) {
            if (method_exists($user, 'bootSoftDeletes') && !$user->forceDeleting) {
                return;
            }

            $user->roles()->sync([]);
            $user->permissions()->sync([]);
        });
    }
public static function bootLaratrustUserTrait ( ) { $ flushCache = function ( $ user ) { $ user -> flushCache ( ) ; } ; // If the user doesn't use SoftDeletes. if ( method_exists ( static :: class , 'restored' ) ) { static :: restored ( $ flushCache ) ; } static :: deleted ( $ flushCache ) ; static :: saved ( $ flushCache ) ; static :: deleting ( function ( $ user ) { if ( method_exists ( $ user , 'bootSoftDeletes' ) && ! $ user -> forceDeleting ) { return ; } $ user -> roles ( ) -> sync ( [ ] ) ; $ user -> permissions ( ) -> sync ( [ ] ) ; } ) ; }
Boots the user model and attaches event listener to
remove the many-to-many records when trying to delete.
Will NOT delete any records if the user model uses soft deletes.

@return void|bool
Boots the user model and attaches event listener to remove the many - to - many records when trying to delete . Will NOT delete any records if the user model uses soft deletes .