Tenants
Explanation of tenants and how to manage them.
Each tenant in this package reflects one website owned by a customer. A website serves the same content to one or multiple hostnames.
- The customer is a legal entity, person or company, who claims ownership of the websites, domains and other objects managed in the tenancy application.
- The website serves the visitors of the connected domain names the content you configured for the tenant through global and/or tenant routes.
- The hostname is configured per website and defines which website should be shown when requesting the specified hostname. A hostname can be anything from a complete domain
example.com
to a subdomainmy.sub.example.com
.
TIP
A website does not necessarily need a hostname. You can set up a tenant website without having configured any resolving domains.
Example code helping you manage tenants
First, let's create a customer.
$customer = app('Hyn\Tenancy\Contracts\CustomerRepositoryContract')->create([
'name'=> 'some-one',
'email' => '[email protected]'
]);
Now let's create a new tenant website using this customer.
$website = app('Hyn\Tenancy\Contracts\WebsiteRepositoryContract')->create([
'identifier'=> 'some-site',
'customer_id' => $customer->id
]);
Without a hostname, you can't hit the tenant website to see your code/application. So let's configure a hostname with the tenant website that is owned by the customer.
$hostname = app('Hyn\Tenancy\Contracts\HostnameRepositoryContract')->create([
'hostname'=> 'some-hostname.org',
'website_id' => $website->id,
'customer_id' => $customer->id
]);
Updated less than a minute ago