PHPackages                             callcocam/tall-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. [Database &amp; ORM](/categories/database)
4. /
5. callcocam/tall-tenant

ActivePackage[Database &amp; ORM](/categories/database)

callcocam/tall-tenant
=====================

Laravel package for multi-tenant with one or more databases, Pacote laravel para mult-tenant com um ou mais database.

06PHP

Since Dec 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/callcocam/tall-tenant)[ Packagist](https://packagist.org/packages/callcocam/tall-tenant)[ RSS](/packages/callcocam-tall-tenant/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

\#TAL TENANT

\#DEFAULT COMMANDS

```
./vendor/bin/sail artisan migrate --database=landlord --path=/database/migrations/landlord
./vendor/bin/sail artisan migrate:fresh --database=landlord --path=/database/migrations/landlord

 ./vendor/bin/sail artisan db:seed --class=LandlordSeeder

 ./vendor/bin/sail artisan db:seed --class=RoleAndPermissionsSeeder

```

```
 ./vendor/bin/sail artisan migrate --database=mysql
 ./vendor/bin/sail artisan migrate:fresh --database=mysql

./vendor/bin/sail artisan db:seed --class=TenantSeeder

./vendor/bin/sail artisan db:seed --class=MenusSeeder

```

\#DOC TENANT

You can tell Landlord to automatically scope by a given Tenant by calling addTenant(), either from the Landlord facade, or by injecting an instance of TenantManager().

You can pass in either a tenant column and id:

Landlord::addTenant('tenant\_id', 1); Or an instance of a Tenant model:

$tenant = Tenant::find(1);

Landlord::addTenant($tenant); If you pass a Model instance, Landlord will use Eloquent’s getForeignKey() method to decide the tenant column name.

You can add as many tenants as you need to, however Landlord will only allow one of each type of tenant at a time.

To remove a tenant and stop scoping by it, simply call removeTenant():

Landlord::removeTenant('tenant\_id');

// Or you can again pass a Model instance: $tenant = Tenant::find(1);

Landlord::removeTenant($tenant); You can also check whether Landlord currently is scoping by a given tenant:

// As you would expect by now, $tenant can be either a string column name or a Model instance Landlord::hasTenant($tenant); And if for some reason you need to, you can retrieve Landlord's tenants:

// $tenants is a Laravel Collection object, in the format 'tenant\_id' =&gt; 1 $tenants = Landlord::getTenants(); Setting up your Models To set up a model to be scoped automatically, simply use the BelongsToTenants trait:

use Illuminate\\Database\\Eloquent\\Model; use Tall\\Tenant\\BelongsToTenants;

class ExampleModel extends Model { use BelongsToTenants; } If you’d like to override the tenants that apply to a particular model, you can set the $tenantColumns property:

use Illuminate\\Database\\Eloquent\\Model; use Tall\\Tenant\\BelongsToTenants;

class ExampleModel extends Model { use BelongsToTenants;

```
public $tenantColumns = ['tenant_id'];

```

} Creating new Tenant scoped Models When you create a new instance of a Model which uses BelongsToTenants, Landlord will automatically add any applicable Tenant ids, if they are not already set:

// 'tenant\_id' will automatically be set by Landlord $model = ExampleModel::create(\['name' =&gt; 'whatever'\]); Querying Tenant scoped Models After you've added tenants, all queries against a Model which uses BelongsToTenant will be scoped automatically:

// This will only include Models belonging to the current tenant(s) ExampleModel::all();

// This will fail with a ModelNotFoundForTenantException if it belongs to the wrong tenant ExampleModel::find(2); Note: When you are developing a multi tenanted application, it can be confusing sometimes why you keep getting ModelNotFound exceptions for rows that DO exist, because they belong to the wrong tenant.

Landlord will catch those exceptions, and re-throw them as ModelNotFoundForTenantException, to help you out :)

If you need to query across all tenants, you can use allTenants():

// Will include results from ALL tenants, just for this query ExampleModel::allTenants()-&gt;get() Under the hood, Landlord uses Laravel's anonymous global scopes. This means that if you are scoping by multiple tenants simultaneously, and you want to exclude one of the for a single query, you can do so:

// Will not scope by 'tenant\_id', but will continue to scope by any other tenants that have been set ExampleModel::withoutGlobalScope('tenant\_id')-&gt;get();

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 56.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7425411?v=4)[Claudio Campos](/maintainers/callcocam)[@callcocam](https://github.com/callcocam)

---

Top Contributors

[![webcall](https://avatars.githubusercontent.com/u/7212238?v=4)](https://github.com/webcall "webcall (9 commits)")[![SigaSmart](https://avatars.githubusercontent.com/u/29053245?v=4)](https://github.com/SigaSmart "SigaSmart (7 commits)")

### Embed Badge

![Health badge](/badges/callcocam-tall-tenant/health.svg)

```
[![Health](https://phpackages.com/badges/callcocam-tall-tenant/health.svg)](https://phpackages.com/packages/callcocam-tall-tenant)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
