#Circumvent Multi tenancy

5 messages · Page 1 of 1 (latest)

rough mortar
#

and this And this EloquentQuery:

    public static function getEloquentQuery(): Builder
    {
        $user = Auth::user();
        $viewAll = session('view_all_networks', false);

        if ($user->is_admin) {
            if ($viewAll) {
                info('Admin user viewing all networks.');
                return parent::getEloquentQuery();
            } else {
                $tenant = Filament::getTenant();
                if ($tenant) {
                    info('Admin user viewing only their tenant networks. Current tenant ID: ' . $tenant->id);
                    return parent::getEloquentQuery()->where('organization_id', $tenant->id);
                } else {
                    info('Admin user viewing networks with no tenant.');
                    return parent::getEloquentQuery()->whereNull('organization_id');
                }
            }
        } else {
            
            info('Non-admin user viewing their tenant networks only.');
            $tenant = Filament::getTenant();
            if ($tenant) {
                info('Current tenant ID: ' . $tenant->id);
                return parent::getEloquentQuery()->where('organization_id', $tenant->id);
            } else {
                info('No tenant found for non-admin.');
                return parent::getEloquentQuery()->whereNull('organization_id');
            }
        }
    }

however, it does update the button, but doesn't update the table.. i have tried some different methods, like redirecting after button has been pressed, and i'm trying to avoid using multiple panels.

Any suggestions?

lilac delta
rough mortar
rough mortar
#

Nvm i fixed it! By using $isScopedToTenant!

lilac delta
#

Sorry!! I must have replied to the wrong topic.