mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 02:04:03 +00:00
1 KiB
1 KiB
| title | description | extends | section |
|---|---|---|---|
| Creating Tenants | Creating tenants with stancl/tenancy — A Laravel multi-database tenancy package that respects your code.. | _layouts.documentation | content |
Creating Tenants
Make sure your database is correctly [configured]({{ $page->link('configuration/#database') }}) before creating tenants.
To create a tenant, you can use
tenant()->create('tenant1.yourapp.com');
Tip: All domains under
.localhostare routed to 127.0.0.1 on most operating systems. This is useful for development.
If you want to set some data while creating the tenant, you can pass an array with the data as the second argument:
tenant()->create('tenant2.yourapp.com', [
'plan' => 'free'
]);
The create method returns an array with tenant information (uuid, domain and whatever else you supplied).
Note: Creating a tenant doesn't run migrations automatically. You have to do that yourself.