where('user_id', $user->getKey()); $hasAnyActiveMembership = Schema::hasColumn('workspaces', 'archived_at') ? $membershipQuery ->join('workspaces', 'workspace_memberships.workspace_id', '=', 'workspaces.id') ->whereNull('workspaces.archived_at') ->exists() : $membershipQuery->exists(); if (! $hasAnyActiveMembership) { return '/admin/no-access'; } return '/admin'; } }