Adeko 14.1
Request
Download
link when available

Spatie multitenancy. Only use the instructions on this pa...

Spatie multitenancy. Only use the instructions on this page if you want each of your tenants to have their own database. The package ships with a class named DomainTenantFinder that will try to find a Tenant whose domain attribute matches with the hostname of the current request. One named landlord, which points to laravel-multitenancy Before using the following instructions, make sure you have performed the base installation steps first. Only use the instructions on this page if you want to use one database. The philosophy of this package is that it should only provide the bare essentials to enable multitenancy. To use that tenant finder, specify its class name in the tenant_finder key of the multitenancy config file. laravel-multitenancy Before using the following instructions, make sure you have performed the base installation steps first. First, you must publish and run the migration: php artisan vendor:publish --provider="Spatie laravel-multitenancy This package can be installed via composer: composer require spatie/laravel-multitenancy Publishing the config file You must publish the config file: php artisan vendor:publish --provider="Spatie\Multitenancy\MultitenancyServiceProvider" --tag="multitenancy-config" This is the default content of the config file that will be published at config/multitenancy. You’ll learn how to Jul 11, 2025 · This document provides a comprehensive overview of the spatie/laravel-multitenancy package, explaining its philosophy, architecture, and core systems. This package enables Laravel applications to serve multiple tenants through a flexible, unopinionated approach to multitenancy. composer require spatie/laravel-multitenancy:^4. php Although spatie/laravel-multitenancy supporting single databases, it doesn't come with query scopes (and seems like there are no plans to add them, as you can see here: https://github. The database name used will be in the database attribute of the Tenant model. The platform uses a landlord/tenant database split powered by Spatie Laravel Multitenancy: Landlord database — users, organizations, organization memberships, tenant database records, platform event store The Spatie\Multitenancy\Tasks\SwitchDatabaseTask can switch the configured database name of the tenant database connection. The package can determine which tenant should be the current tenant for the request. Jobs that should be tenant aware should implement the empty marker interface Spatie\Multitenancy\Jobs\TenantAware or should be added to the config tenant_aware_jobs. 0 Removed UsesTenantModel trait Remove any reference to our old trait Spatie\Models\Concerns\UsesTenantModel, because now the right . x version, we have introduced the contract concept to the Tenant so that any model could implement the interface. Embrace multi-tenancy to enhance your application’s architecture and user experience. This package can make a Laravel app tenant aware. // in laravel-multitenancy On this page Option 1: extending the Option 2: using a model of your own Performing actions when a tenant gets created laravel-multitenancy Docs Laravel-multitenancy Using-tasks-to-prepare-the-environment Creating your own task When a tenant is made the current one, the package will run the makeCurrent method of all tasks configured in the switch_tenant_tasks key of the multitenancy config file. Mar 23, 2025 · Conclusions Implementing multi-tenancy in Laravel with the Spatie package offers a robust solution for managing multiple tenants efficiently. // in multitenancy. Feb 10, 2026 · README Unopinionated multitenancy package for Laravel This package can make a Laravel app tenant aware. Configuring the database connections When using a separate database for each tenant, your Laravel app needs two database connections. laravel-multitenancy In the 4. This is done by a TenantFinder. In the multitenancy config file, you specify the tenant finder in the tenant_finder key. It has a name of spatie/laravel-multitenancy and has a slightly different philosophy than others. The key philosophy of this package is that it should provide only the bare essentials to enable multi-tenancy and to make your application tenant aware. The package contains a lot of niceties such as making queued jobs tenant aware, making an artisan command run for each tenant, an easy way to set a connection on a model, and much more. com/spatie/laravel-multitenancy/issues/124), so you would need to create them manually. Oct 16, 2025 · This walkthrough shows a pragmatic, production-friendly approach to multi-tenant authorization using Spatie’s multitenancy package plus Spatie’s permission package. By following the steps and best practices outlined in this article, you can create scalable, secure, and maintainable applications. Migrating the database With the database connection set up, we can migrate the landlord database. laravel-multitenancy Per request, the package can determine the "current" tenant. php: <?php use laravel-multitenancy At the start of each request, the package will try to determine which tenant should be active for the current request. The package ships with a DomainTenantFinder that will make the tenant active whose domain attribute value matches the host of the current request. The first step to reach our goal is upgrading our package version. Are you a visual learner? Then watch this video that covers how you can use laravel-multitenancy and how it works under the hood. 5xnsi, vkqpx, 3qv7c, mbfjq0, wnqbmv, nnj3lj, rqu4, su39, e9kwn, 1jxqf,