Download the PHP package thisisdevelopment/laravel-tenants without Composer
On this page you can find all versions of the php package thisisdevelopment/laravel-tenants. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thisisdevelopment/laravel-tenants
More information about thisisdevelopment/laravel-tenants
Files in thisisdevelopment/laravel-tenants
Package laravel-tenants
Short Description A package to provide multi tenancy to laravel applications with minimal effort
License MIT
Informations about the package laravel-tenants
Laravel tenants
A package to provide easy multi tenancy in your laravel application
After a simple setup (see below) you will have a fully functional multi tenancy app which out of the box:
- allows for many-to-many relationship between your users and tenant objects.
- supports easy switching between multiple tenants for a user which has access to multiple tenants (via
x-selected-tenant
header or viaselected-tenant
cookie) - once switched by default only allows access to a single tenant object and you can easily implement tenant scoped models (see setup #4)
- allows to use tinker (or any other cli command) with a specific tenant (--tenant=
) - all jobs submitted from a context where a tenant is selected will use that tenant when executing from a queue
- when a tenant model is created the tenant database is automatically created
For an example see https://github.com/thisisdevelopment/laravel-tenants-example
Todo
- integrate with laravel-test-snapshot
- proper seed support
- support sqlite
- cleanup
- ..
Setup
To setup multi tenancy with this package you'll need the following steps
1) include this package
2) find the model which serves as tenant (eg: customer/user) and implement our Tenant
contract
and register it in your AppServiceProvider
class
3) find the models which should live in tenant specific databases and use our onTenantDB
trait
and move all of the migrations / seeders for these models to
the database/migrations/<tenant model name>
/ database/seeds/<tenant model name>
so they will only be used for tenant databases.
4) find the models which should be restricted once you switched to the tenant db and use our TenantScoped
trait
5) (optional) find the model which you authenticate with and let it be responsible for providing the allowedTenants + defaultTenant by implementing the TenantAuth
interface by using the ProvidesTenantAuth
trait
All versions of laravel-tenants with dependencies
tenancy/framework Version ^1.0
tenancy/hooks-migration Version ^1.0
tenancy/identification-driver-console Version ^1.0
tenancy/identification-driver-queue Version ^1.0