tenancy-docs/source/2.x/creating-tenants.blade.md
2019-09-18 15:45:39 +02:00

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::new()->withDomains(['tenant1.yourapp.com'])->withData(['plan' => 'free'])->save();

Tip: All domains under .localhost are 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.