Laratrust\Traits\LaratrustUserTrait::bootLaratrustUserTrait PHP Method

bootLaratrustUserTrait() public static method

Boot the user model Attach 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.
public static bootLaratrustUserTrait ( ) : void | boolean
return void | boolean
    public static function bootLaratrustUserTrait()
    {
        $flushCache = function ($user) {
            $user->flushCache();
            return true;
        };
        // If the user doesn't use SoftDeletes
        if (method_exists(Config::get('auth.providers.users.model'), 'restored')) {
            static::restored($flushCache);
        }
        static::deleted($flushCache);
        static::saved($flushCache);
        static::deleting(function ($user) {
            if (!method_exists(Config::get('auth.providers.users.model'), 'bootSoftDeletes')) {
                $user->roles()->sync([]);
            }
        });
    }