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
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