0057-laravel-multi-tenancy

Structure Laravel projects with central and tenant-scoped actions, jobs, and tests.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0057-laravel-multi-tenancy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 0057-laravel-multi-tenancy
Source: https://github.com/MrJmpl3/codex_____data_____configuration/tree/main/skills/0057-laravel-multi-tenancy
Command: npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0057-laravel-multi-tenancy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves the complexity of building multi-tenant Laravel applications by keeping central (non-tenant) and tenant-scoped (tenanted) logic separated while ensuring queries and background jobs run in the correct tenant context.

Core Features & Use Cases

  • Central vs Tenanted organization: Separate actions and DTOs for tenant management and tenant-specific business logic.
  • Tenant-aware data access: Ensure tenant scoping is applied to queries so models do not require explicit tenant_id handling.
  • Tenant context-safe background jobs: Preserve tenant context when dispatching queued jobs using tenant-aware job patterns.
  • Tenant identification and routing: Initialize tenancy by domain, subdomain, or request header, and route requests to central or tenant handlers.
  • Testing support for both contexts: Provide test infrastructure that creates isolated tenant databases, manages transactions, and runs correct base test cases by directory.

Quick Start

Use the 0057-laravel-multi-tenancy skill to structure your Laravel project for Stancl Tenancy with central/tenanted actions, tenant-aware jobs, and directory-based test setup.

Frequently Asked Questions about 0057-laravel-multi-tenancy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I isolate tenant data automatically in a Laravel multi-tenancy application?

Automatic tenant isolation in Laravel is achieved by applying tenant scoping to queries so models do not require explicit tenant_id handling, ensuring data separation without manual filtering.

How do I preserve tenant context when dispatching queued jobs in Laravel?

To preserve tenant context in queued jobs, Laravel multi-tenancy uses tenant-aware job patterns that maintain the correct tenant scope when background jobs execute, preventing cross-tenant data leaks.

Does Laravel multi-tenancy support separate central and tenant-scoped testing?

Laravel multi-tenancy supports testing both central and tenant contexts by providing test infrastructure that creates isolated tenant databases, manages transactions, and runs correct base test cases by directory.

What's the best way to organize central versus tenanted actions and DTOs in Laravel SaaS?

The best way to organize central versus tenanted logic is separating actions and DTOs for tenant management and tenant-specific business logic, keeping central administration distinct from tenant-scoped operations.

Can I initialize tenancy by domain or subdomain for routing in Laravel?

You can initialize tenancy by domain, subdomain, or request header, routing requests to central or tenant handlers to correctly identify and scope tenant-specific business operations.

Why do I need Stancl Tenancy for database isolation per tenant in Laravel?

Stancl Tenancy is needed to solve the complexity of keeping tenant isolation correct while separating central administration from tenant-scoped business operations in SaaS designs requiring database isolation per tenant.