mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
Update docs for 2.x
This commit is contained in:
parent
60d320ad6a
commit
71287b36cb
9 changed files with 114 additions and 22 deletions
|
|
@ -7,15 +7,14 @@ section: content
|
|||
|
||||
# Custom Database Names {#custom-database-names}
|
||||
|
||||
If you want to specify the tenant's database name, set the `tenancy.database_name_key` configuration key to the name of the key that is used to specify the database name in the tenant storage. You must use a name that you won't use for storing other data, so it's recommended to avoid names like `database` and use names like `_stancl_tenancy_database_name` instead. Then just give the key a value during the tenant creation process:
|
||||
To set the a database name for a tenant, use set `_tenancy_db_name` key in the tenant's storage.
|
||||
|
||||
You should do this during the tenant creation process, to make sure the database is created with the right name:
|
||||
|
||||
```php
|
||||
>>> tenancy()->create('example.com', [
|
||||
'_stancl_tenancy_database_name' => 'example_com'
|
||||
use Stancl\Tenancy\Tenant;
|
||||
|
||||
Tenant::create('example.com', [
|
||||
'_tenancy_db_name' => 'example_com'
|
||||
])
|
||||
=> [
|
||||
"id" => "49670df0-1a87-11e9-b7ba-cf5353777957",
|
||||
"domain" => "example.com",
|
||||
"_stancl_tenancy_database_name" => "example_com",
|
||||
]
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue