PHP code example of jeffersonsimaogoncalves / multitenancy
1. Go to this page and download the library: Download jeffersonsimaogoncalves/multitenancy 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/ */
jeffersonsimaogoncalves / multitenancy example snippets
use Spatie\Permission\Traits\HasRoles;
use JeffersonSimaoGoncalves\Multitenancy\Traits\HasTenants;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasTenants, HasRoles;
// ...
}
Tenant::create([
'name' => 'An Identifying Name',
'domain' => 'tenant1'
]);
Tenant::create([
'name' => 'A Second Customer',
'domain' => 'tenant2'
]);
Route::group(['middleware' => ['tenant.guest']], function () {
// ...
});
use Illuminate\Database\Eloquent\Model;
use JeffersonSimaoGoncalves\Multitenancy\Traits\BelongsToTenant;
class Product extends Model
{
use BelongsToTenant;
// ...
}