DanTheDJ / multitenant

The minimalist Laravel MultiTenant package enables easy multi-tenant applications by dynamically setting the database connection + name and adding a globally available --tenant option to Artisan. Enjoy!
MIT License
14 stars 4 forks source link

Database not getting created #5

Closed xyrintech closed 7 years ago

xyrintech commented 7 years ago

How can we create a database for every tenant when we register.

DanTheDJ commented 7 years ago

In order to create a tenant you need to create a new instance and then save:

$tenant = new \DanTheDJ\MultiTenant\Tenant();
$tenant->name = 'ACME Inc.';
$tenant->email = 'person@acmeinc.com';
$tenant->subdomain = 'acme';
$tenant->alias_domain = 'acmeinc.com';
$tenant->connection = 'tenant_db';
$tenant->meta = ['phone' => '123-123-1234'];
$tenant->save();

Maybe place this in your register script.