Skip to content

feat: tenants to base structure - #76

Merged
danielhe4rt merged 34 commits into
3.xfrom
feat/tenants
Nov 4, 2025
Merged

feat: tenants to base structure#76
danielhe4rt merged 34 commits into
3.xfrom
feat/tenants

Conversation

@danielhe4rt

@danielhe4rt danielhe4rt commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

This pull request introduces multi-tenancy support to the Badge and Character modules by adding tenant_id fields and enforcing tenant-aware logic throughout models, factories, DTOs, entities, validation, routes, and tests. It also updates relevant middleware and actions to ensure all operations are scoped to the correct tenant, and modifies tests to use tenant-specific data.

Multi-tenancy support and enforcement:

  • Added tenant_id as a required attribute to the Badge, Character, and PastSeason models, their factories, and their $fillable arrays to ensure all records are associated with a tenant. [1] [2] [3] [4] [5] [6]
  • Updated DTOs (NewBadgeDTO) and entities (BadgeEntity) to require and serialize tenant_id, and to expect it in their static constructors. [1] [2] [3] [4] [5]
  • Added validation for tenant_id in badge creation requests.

Route and middleware updates:

  • Added VerifyIfHasTenantProviderMiddleware to both badge and character API route groups to enforce tenant context on all endpoints. [1] [2]

Tenant-aware logic in actions:

  • Updated FindCharacterIdByUserId action to query characters by both tenant_id (from the request) and user_id, ensuring tenant isolation. [1] [2]
  • Updated actions that previously referenced userId to use modelId for improved provider/character linkage. [1] [2]

Test updates for multi-tenancy:

  • Refactored feature and unit tests for badges and characters to create and use tenant-specific data, including factories for tenants and passing tenant_id in payloads and headers. [1] [2] [3] [4] [5] [6] [7] [8]

Factory improvements:

  • Updated factories for badges, characters, and past seasons to generate associated tenants automatically. [1] [2] [3]

These changes collectively ensure all badge and character operations are properly scoped to a tenant, laying the groundwork for robust multi-tenant support.

danielhe4rt and others added 28 commits November 2, 2025 17:29
- Conditionally drop foreign key constraint for non-SQLite databases
Signed-off-by: Gabriel do Carmo Vieira <48625433+gvieira18@users.noreply.github.com>
@danielhe4rt danielhe4rt changed the title feat: tenants feat: tenants to base structure Nov 4, 2025
@danielhe4rt
danielhe4rt marked this pull request as ready for review November 4, 2025 16:21
@danielhe4rt
danielhe4rt merged commit 4db673f into 3.x Nov 4, 2025
1 check passed
@danielhe4rt
danielhe4rt deleted the feat/tenants branch November 4, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants