mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
986 B
986 B
| title | description | extends | section |
|---|---|---|---|
| Creating Tenants | Creating tenants.. | _layouts.documentation_v2 | 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::new()->withDomains(['tenant1.yourapp.com'])->withData(['plan' => 'free'])->save();
Tip: All domains under
.localhostare routed to 127.0.0.1 on most operating systems. This is useful for development.
The withDomains() and withData() methods are optional.
You can also create a tenant using the Tenant::create method:
$domains = ['tenant1.myapp.com', 'tenant1.com'];
Tenant::create($domains, [
'plan' => 'free',
]);
Note: Creating a tenant doesn't run migrations automatically. You have to do that yourself.