1. Go to this page and download the library: Download romegadigital/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/ */
use Spatie\Permission\Traits\HasRoles;
use RomegaDigital\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 RomegaDigital\Multitenancy\Traits\BelongsToTenant;
class Product extends Model
{
use BelongsToTenant;
// ...
}