PHP code example of aura-is-here / laravel-multi-tenant

1. Go to this page and download the library: Download aura-is-here/laravel-multi-tenant library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aura-is-here / laravel-multi-tenant example snippets


AuraIsHere\LaravelMultiTenant\LaravelMultiTenantServiceProvider::class,

'TenantScope' => AuraIsHere\LaravelMultiTenant\Facades\TenantScopeFacade::class



use AuraIsHere\LaravelMultiTenant\Traits\TenantScopedModelTrait;

class Model extends Eloquent {

    use TenantScopedModelTrait;
}

$models = Model::all(); // Only the Models with the correct tenant id

$model = Model::find(1); // Will fail if the Model with `id` 1 belongs to a different tenant

$newModel = Model::create(); // Will have the tenant id added automatically

$allModels = Model::allTenants()->get(); //You can run any fluent query builder methods here, and they will not be scoped by tenant
bash
php artisan vendor:publish --provider="AuraIsHere\LaravelMultiTenant\LaravelMultiTenantServiceProvider"