PHPackages                             henryavila/laravel-nova-multitenancy - 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. [Admin Panels](/categories/admin)
4. /
5. henryavila/laravel-nova-multitenancy

ActiveLibrary[Admin Panels](/categories/admin)

henryavila/laravel-nova-multitenancy
====================================

Integrate the multi tenancy single database in Laravel Nova.

v3.3.0(1y ago)3148↓100%[2 PRs](https://github.com/henryavila/laravel-nova-multitenancy/pulls)proprietaryPHPPHP ^8.2

Since Apr 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/henryavila/laravel-nova-multitenancy)[ Packagist](https://packagist.org/packages/henryavila/laravel-nova-multitenancy)[ Docs](https://github.com/henryavila/laravel-nova-multitenancy)[ RSS](/packages/henryavila-laravel-nova-multitenancy/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (14)Versions (17)Used By (0)

Integrate the multitenancy single database in Laravel Nova.
===========================================================

[](#integrate-the-multitenancy-single-database-in-laravel-nova)

[![Latest Version on Packagist](https://camo.githubusercontent.com/886314bf2d24850126c289c49834c3e33a02da1eb4a701b858514986a1018448/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68656e72796176696c612f6c61726176656c2d6e6f76612d6d756c746974656e616e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/henryavila/laravel-nova-multitenancy)[![GitHub Tests Action Status](https://camo.githubusercontent.com/48d7815870961f23d84a05973cc1fb843799e476042fe7f8c6b92dc90f6fc3ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68656e72796176696c612f6c61726176656c2d6e6f76612d6d756c746974656e616e63792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/henryavila/laravel-nova-multitenancy/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/383ccef5732ba69e52c54732b3f207f55fb69a70300be935d8a8c50c1907fd31/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68656e72796176696c612f6c61726176656c2d6e6f76612d6d756c746974656e616e63792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/henryavila/laravel-nova-multitenancy/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/b7bdb6eb194cc3d38545bd5eef7ed660750dedac970173ccdfb629dfa0162911/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68656e72796176696c612f6c61726176656c2d6e6f76612d6d756c746974656e616e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/henryavila/laravel-nova-multitenancy)

Integrate the multitenancy single database in Laravel Nova.

This package is based on . So logic and config of spatie/laravel-multitenancy still aplies

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require henryavila/laravel-nova-multitenancy
```

You can publish the config, view, migrations and translation with:

```
php artisan vendor:publish --provider="HenryAvila\LaravelNovaMultitenancy\LaravelNovaMultitenancyServiceProvider"
```

The views file will be published, personalize it at your will. Don't forget to run `npm run build`

You can run the migration with (To create the Tenant table)

```
php artisan migrate
```

Edit the `app\Http\Kernel.php` file adding an entry in web group and creating the tenant group

```
protected $middlewareGroups = [
    // ...

    'web' => [
        // ...
        \HenryAvila\LaravelNovaMultitenancy\Http\Middleware\SetTenantMiddleware::class,
    ],

    // ...

    'tenant' => [
        \HenryAvila\LaravelNovaMultitenancy\Http\Middleware\NeedsTenant::class,
        \HenryAvila\LaravelNovaMultitenancy\Http\Middleware\EnsureValidTenantSession::class,
    ]
];
```

If you activated (User Impersonation)\[\] on Laravel Nova, you must set up this event Listeners.

Edit the file `App\Providers\EventServiceProvider` and add:

```
 protected $listen = [
        \Laravel\Nova\Events\StartedImpersonating::class  => [
            \HenryAvila\LaravelNovaMultitenancy\Listeners\ClearTenantSessionListener::class,
        ],
        \Laravel\Nova\Events\StoppedImpersonating::class => [
            \HenryAvila\LaravelNovaMultitenancy\Listeners\ClearTenantSessionListener::class,
        ],
];
```

Make your `User` model extends `\HenryAvila\LaravelNovaMultitenancy\Models\User`

If you want to customize the Tenant model, change it in config file

Add the trait `\HenryAvila\LaravelNovaMultitenancy\Traits\ModelWithTenant` to all models that are tenant aware

Add to your `database` file a `tenant_connection` entry with the tenant db connection. See:

```
return [
    // database.php
    'tenant_connection' => env('DB_TENANT_CONNECTION', 'tenant'),
```

This is the relation between the connections and the database

NameDatabasedefaultLandlord databasetenant\_connectionTenant database**PS.:** Don't forget to create this connections in `database.connections` config file.

Usage
-----

[](#usage)

To protect a specific route, just add the 'tenant' middleware to route

```
// in a routes file

Route::middleware('tenant')->group(function() {
    // routes
});
```

If you receive an error: `Route [login] not defined.`. Remember to change the route from `login` to `nova.login` in your `App\Http\Middleware\Authenticate` file

```
protected function redirectTo($request)
{
    return $request->expectsJson() ? null : route('nova.login');
}
```

Another option to don't define the tenant to an route is set the following `default` data to route declaration

```
Route::get('/', [Controller::class, 'index'])
		->defaults(\HenryAvila\LaravelNovaMultitenancy\LaravelNovaMultitenancy::SKIP_ROUTE, true);
```

If the `Tenant` has `domains` relationship, allow to define the current tenant based on current domain. The `domains` relation model, must contain an `fqdn` attribute with the fqdn domain

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Henry Ávila](https://github.com/henryavila)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 76% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% 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.

###  Release Activity

Cadence

Every ~31 days

Recently: every ~55 days

Total

12

Last Release

711d ago

Major Versions

2.2.0 → 3.0.02023-08-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/f05a7a5057256071ec7089d62dcf7b47d5700fe1189e7fceac681f93f2894a85?d=identicon)[henryavila](/maintainers/henryavila)

---

Top Contributors

[![henryavila](https://avatars.githubusercontent.com/u/8429941?v=4)](https://github.com/henryavila "henryavila (56 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")

---

Tags

laravelhenryavilalaravel-nova-multitenancy

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/henryavila-laravel-nova-multitenancy/health.svg)

```
[![Health](https://phpackages.com/badges/henryavila-laravel-nova-multitenancy/health.svg)](https://phpackages.com/packages/henryavila-laravel-nova-multitenancy)
```

###  Alternatives

[guava/filament-knowledge-base

A filament plugin that adds a knowledge base and help to your filament panel(s).

203110.1k1](/packages/guava-filament-knowledge-base)[jhumanj/laravel-model-stats

Model statistics dashboard for your Laravel Application

24213.2k](/packages/jhumanj-laravel-model-stats)[webid/druid

Laravel Filament based CMS

192.1k](/packages/webid-druid)[alareqi/filament-pwa

A comprehensive PWA (Progressive Web App) plugin for Filament v3 and v4 admin panels with offline functionality, installation prompts, and icon generation.

112.5k](/packages/alareqi-filament-pwa)

PHPackages © 2026

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