Download the PHP package maize-tech/laravel-tenant-aware without Composer
On this page you can find all versions of the php package maize-tech/laravel-tenant-aware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download maize-tech/laravel-tenant-aware
More information about maize-tech/laravel-tenant-aware
Files in maize-tech/laravel-tenant-aware
Download maize-tech/laravel-tenant-aware
More information about maize-tech/laravel-tenant-aware
Files in maize-tech/laravel-tenant-aware
Vendor maize-tech
Package laravel-tenant-aware
Short Description Laravel Tenant Aware
License MIT
Homepage https://github.com/maize-tech/laravel-tenant-aware
Package laravel-tenant-aware
Short Description Laravel Tenant Aware
License MIT
Homepage https://github.com/maize-tech/laravel-tenant-aware
Please rate this library. Is it a good library?
Informations about the package laravel-tenant-aware
# Laravel Tenant Aware [![Latest Version on Packagist](https://img.shields.io/packagist/v/maize-tech/laravel-tenant-aware.svg?style=flat-square)](https://packagist.org/packages/maize-tech/laravel-tenant-aware) [![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/maize-tech/laravel-tenant-aware/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/maize-tech/laravel-tenant-aware/actions?query=workflow%3Arun-tests+branch%3Amain) [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/maize-tech/laravel-tenant-aware/php-cs-fixer.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/maize-tech/laravel-tenant-aware/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/maize-tech/laravel-tenant-aware.svg?style=flat-square)](https://packagist.org/packages/maize-tech/laravel-tenant-aware) Easily integrate single-database multi tenant features into your Laravel application. ## Installation You can install the package via composer: You can publish the config file with: This is the contents of the published config file: ## Usage ### Configuration Before getting started, make sure to fill in the `model` and `foreign_key_name` attributes under `config/tenant-aware.php`. Also, don't forget to define your own `TenantCurrentAction` and `TenantLandlordAction` actions in order to retrieve both the current and landlord tenants. For example, if you're using Spatie's [laravel-multitenancy](https://github.com/spatie/laravel-multitenancy) package your custom actions could look like this: ### Basic To use the package, add the `Maize\TenantAware\BelongsToTenant` trait to the models where you want to use the multi-tenant features. Remember all your multi-tenant models should have the tenant field specified in `foreign_key_name` attribute under `config/tenant-aware.php`. Once done, when querying any of your multi-tenant models you will only retrieve entities under your same tenant. Let's say, for example, we have this list of users in our database, and the currently authenticated user is part of the tenant `2`: | id | email | tenant_id | created_at | updated_at | |-----|--------------------|-----------|------------|------------| | 1 | [email protected] | 2 | // | // | | 2 | [email protected] | 2 | // | // | | 3 | [email protected] | 2 | // | // | | 4 | [email protected] | 3 | // | // | When querying the User model, you would only get the first three users: ### Querying global entities Have a model who should handle both global and tenant related entities? No worries! All you have to do is add the model class name to the `models.global` attribute under `config/tenant-aware.php`. Also, make sure your landlord tenant is returned on your custom `TenantLandlordAction` action class! Let's say you have an e-learning multi-tenant platform with both global courses and custom courses for each tenant. | id | name | tenant_id | created_at | updated_at | |-----|-------------------------|-----------|------------|------------| | 1 | Awesome global course A | 1 | // | // | | 2 | Awesome custom course B | 2 | // | // | | 3 | Awesome custom course C | 2 | // | // | | 4 | Awesome custom course D | 3 | // | // | That's what you would get when querying the Course model for a user under tenant `2`: ## Testing ## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. ## Contributing Please see [CONTRIBUTING](https://github.com/maize-tech/.github/blob/main/CONTRIBUTING.md) for details. ## Security Vulnerabilities Please review [our security policy](https://github.com/maize-tech/.github/security/policy) on how to report security vulnerabilities. ## Credits - [Enrico De Lazzari](https://github.com/enricodelazzari) - [All Contributors](../../contributors) ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
All versions of laravel-tenant-aware with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
illuminate/database Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
spatie/laravel-package-tools Version ^1.14.1
illuminate/database Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
spatie/laravel-package-tools Version ^1.14.1
The package maize-tech/laravel-tenant-aware contains the following files
Loading the files please wait ....