Download the PHP package binary-cats/laravel-tenant without Composer
On this page you can find all versions of the php package binary-cats/laravel-tenant. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download binary-cats/laravel-tenant
More information about binary-cats/laravel-tenant
Files in binary-cats/laravel-tenant
Package laravel-tenant
Short Description A Laravel package to add tenants to your application.
License MIT
Homepage https://github.org/binary-cats/laravel-tenant
Informations about the package laravel-tenant
A Simple Laravel Tenancy
This Laravel package allows you to drop-in multi-tenancy. It is a little opinionated and you are free to update and tinker with it.
What it does: Allows you to create a subdomain driven multi-tenant application where each tenant has a single, dedicated subdomain. Your models can be strictly tenantable, or shared between tenants. You are free to turn off subdomain routing.
Installation and Setup
This package requires PHP 7 and Laravel 5.6 or higher. Latest version requires PHP 7.2 and Laravel 7 and above.
THe package will register itself.
Resources
Publish all resources:
or, separately:
Configuration
Usage
- Models
- Events
To fully use Laravel Tenant you need to prepare your models and routing. Laravel Tenant will work best within authenticated environment; If you plan to use if for non-authenticated environment, I suggest creating a Service Provider resolving the tenant via TenantManager
to prevent any data seeping.
Model Setup
Any model you expect to be scoped globally nees to:
- Have a foreign tenant key:
- Import Tenantable trait:
This will add a (Global scope)[https://laravel.com/docs/7.x/eloquent#global-scopes] and an automatic model observer, populating models with current tenant value.
Alternativesly, you can use an OptionalTenantable
trait; it will scope for the exact match of the tenant key OR null value of the model tenant key. Use case scenario is when you have a shared set of models in addition to which the tenant may add their own. Think Gmail folders: Inbox and Trash are labels present in each user's mailbox; however, you are free to add more tags and they are visible only to you.
Caution
Do not include tenant_id into fillable attributes; it should be protected and, preferrably, hidden to make sure you do not accidentally expose tenant information.
Event Setup
Laravel Tenant provides automatic listeners you may hook up to streamline your app:
Subdomains
Laravel Tenant provides resolution logic for subdomains out of the box. If this functionailty is not needed, toggle config tenant.routing.autobind
switch to false
:
Testing
Run the tests with:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- Cyrill Kalita
- All Contributors
Support us
Binary Cats is a web service agency based in Roselle, Illinois.
Does your business depend on our contributions? Reach out! All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
License
The MIT License (MIT). Please see License File for more information.