PHPackages                             binary-cats/laravel-tenant - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. binary-cats/laravel-tenant

AbandonedArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

binary-cats/laravel-tenant
==========================

A Laravel package to add tenants to your application.

3.0.2(5y ago)036MITPHPPHP ^7.2

Since Aug 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/binary-cats/laravel-tenant)[ Packagist](https://packagist.org/packages/binary-cats/laravel-tenant)[ Docs](https://github.org/binary-cats/laravel-tenant)[ RSS](/packages/binary-cats-laravel-tenant/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (5)Used By (0)

A Simple Laravel Tenancy
========================

[](#a-simple-laravel-tenancy)

[![https://github.com/binary-cats/laravel-tenant/actions](https://github.com/binary-cats/laravel-tenant/workflows/PHP%20Composer/badge.svg)](https://github.com/binary-cats/laravel-tenant/workflows/PHP%20Composer/badge.svg)[![https://github.styleci.io/repos/266611306](https://camo.githubusercontent.com/6ea102c4ecc369a9e5405982e38cdc69bb4d914773ed461661aeeed0ea76b7f6/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3236363631313330362f736869656c64)](https://camo.githubusercontent.com/6ea102c4ecc369a9e5405982e38cdc69bb4d914773ed461661aeeed0ea76b7f6/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3236363631313330362f736869656c64)[![https://scrutinizer-ci.com/g/binary-cats/laravel-mailgun-webhooks/](https://camo.githubusercontent.com/6eea73a1716aa70437bd6f325147bb38b8769f6ff993a652abc5d7b69273236e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62696e6172792d636174732f6c61726176656c2d74656e616e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://camo.githubusercontent.com/6eea73a1716aa70437bd6f325147bb38b8769f6ff993a652abc5d7b69273236e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62696e6172792d636174732f6c61726176656c2d74656e616e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)

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.

[![Laravel Tenant](resources/img/laravel-tenant.png)](resources/img/laravel-tenant.png)

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
----------------------

[](#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.

```
php composer require binary-cats\laravel-tenant
```

THe package will register itself.

### Resources

[](#resources)

Publish all resources:

```
php artisan vendor:publish --provider=BinaryCats\\LaravelTenant\\TenantServiceProvider
```

or, separately:

```
php artisan vendor:publish --provider=BinaryCats\\LaravelTenant\\TenantServiceProvider --tag=migrations
php artisan vendor:publish --provider=BinaryCats\\LaravelTenant\\TenantServiceProvider --tag=config
```

### Configuration

[](#configuration)

Usage
-----

[](#usage)

- [Models](#model-setup)
- [Events](#event-setup)

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

[](#model-setup)

Any model you expect to be scoped globally nees to:

1. Have a foreign tenant key:
2. Import Tenantable trait:

```
