PHPackages                             mateusevcarvalho/lara-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mateusevcarvalho/lara-tenant

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mateusevcarvalho/lara-tenant
============================

v1.4(7y ago)011PHP

Since Jul 6Pushed 7y agoCompare

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

READMEChangelog (5)DependenciesVersions (6)Used By (0)

Pacote Laravel desenvolvido para aplicações multitenant.

Instalação
==========

[](#instalação)

1 -Execute o seguinte comando:

```
composer require mateusevcarvalho/lara-tenant

```

Confiruração
============

[](#confiruração)

2 - Adicione o ServiceProvider aos `providers` em `config/app.php`:

```
Modules\MultiTenant\Providers\MultiTenantServiceProvider::class,

```

3 - Adicione também em `config/app.php` no `aliases`:

```
'MultiTenant' => Modules\MultiTenant\Tenant\TenantFacade::class,

```

4 - Acione o middleware em `app/Http/Kernel.php` dentro do array `$routeMiddleware`:

```
'tenant' =>  \Modules\MultiTenant\Http\Middleware\TenantMiddleware::class

```

5 - Publique o model do Tenant: `Lembre-se de criar uma tabela Tenant para dar referencia ao model`:

```
php artisan make:migration create_tenants_table
php artisan vendor:publish --tag=tenantModel

```

Exemplos de uso
===============

[](#exemplos-de-uso)

Nas rotas com autenticação coloque o middleware `tenant` e coloque o: `bindings` para não ter problemas na aplicação e para setar o tenant logado:

```
Route::group(['middleware' => ['auth:api', 'tenant', 'bindings']], function () {
  Route::apiResource('produtos', 'ProdutosController');
});

```

Para setar um tenant use `\MultiTenant::set($tenant)`, e para recuperar: `\MultiTenant::get()`, como o exemplo abaixo:

```
public function store(Request $request)
{
    DB::beginTransaction();
    $formData = $request->all();
    $tenant = Tenant::create(['uuid' => Uuid::generate()->string]);
    \MultiTenant::set($tenant);
    $individuo = $tenant->individuo()->create($formData['individuos']);
    $user = $individuo->user()->create([
        'status' => $formData['users']['status'],
        'email' => $formData['users']['email'],
        'password' => Hash::make($formData['users']['password'])
    ]);
    if ($tenant && $user && $individuo) {
        DB::commit();
        (new CadastrosInicial())->cadastrar();
        return response()->json(compact('tenant', 'user', 'individuo'));
    }
    DB::rollBack();
    return response()->json('Falha interna', 500);
}

```

Na model que terar multitenant use a trait `TenantModels` para automatizar todo e processo de query da model

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

5

Last Release

2597d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25232323?v=4)[Mateus Carvalho](/maintainers/mateusevcarvalho)[@mateusevcarvalho](https://github.com/mateusevcarvalho)

---

Top Contributors

[![mateusevcarvalho](https://avatars.githubusercontent.com/u/25232323?v=4)](https://github.com/mateusevcarvalho "mateusevcarvalho (10 commits)")

### Embed Badge

![Health badge](/badges/mateusevcarvalho-lara-tenant/health.svg)

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

###  Alternatives

[rappasoft/laravel-livewire-tables

A dynamic table component for Laravel Livewire

2.0k3.0M31](/packages/rappasoft-laravel-livewire-tables)[szeidler/composer-patches-cli

28263.9k4](/packages/szeidler-composer-patches-cli)[wa72/html-pretty-min

HTML minifier and indenter that works on the DOM tree

22234.6k8](/packages/wa72-html-pretty-min)[veewee/reflecta

Unleash the Power of Optics in your code!

13477.2k7](/packages/veewee-reflecta)[apen/additional_reports

Useful information in the reports module : xclass, ajax, cliKeys, eID, general status of the system (encoding, DB, php vars...), hooks, compare local and TER extension (diff), used content type, used plugins, ExtDirect... It can really help you during migration or new existing project (to have a global reports of the system).

13170.7k](/packages/apen-additional-reports)[antistatique/swisstopo

Convert GPS (WGS84) to Swiss (LV03 and LV95) coordinates (and vice versa)

1481.8k](/packages/antistatique-swisstopo)

PHPackages © 2026

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