Creating Tenants

Make sure your database is correctly configured before creating tenants.

To create a tenant, you can use

use Stancl\Tenancy\Tenant;

    ->withDomains(['', ''])
    ->withData(['plan' => 'free'])

Tip: All domains under .localhost are routed to on most operating systems. This is useful for development.

The withDomains() and withData() methods are optional.

You can also create a tenant using a single method: Tenant::create:

$domains = ['', ''];
Tenant::create($domains, [
    'plan' => 'free',

Tenant::create() works with both Stancl\Tenancy\Tenant and the facade, \Tenant.

Note: By default, creating a tenant doesn't run migrations automatically. You may change this behavior using the migrate_after_creation configuration.