mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 02:04:03 +00:00
1.3 KiB
1.3 KiB
| title | description | extends | section |
|---|---|---|---|
| Tenant Storage | Tenant storage.. | _layouts.documentation_v2 | content |
Tenant Storage
Tenant storage is where tenants' ids and domains are stored. You can store things like the tenant's plan, subscription information, and tenant-specific application configuration in tenant storage. You may use these functions on Tenant objects:
get (string|array $key)
put (string|array $key, mixed $value = null) // if $key is array, make sure $value is null
To put something into the tenant storage, you can use put() or set().
$tenant->put($key, $value);
$tenant->set($key, $value); // alias for put()
$tenant->put(['key1' => 'value1', 'key2' => 'value2']);
To get something from the storage, you can use get():
tenant()->get($key);
tenant()->get(['key1', 'key2']);
In this example, we're calling the methods on the current tenant —
tenant().
Note:
get(['key1', 'key2'])returns an associative array.
Note that $key has to be a string or an array with string keys. The value(s) can be of any data type. Example with arrays:
>>> tenant()->put('foo', ['a' => 'b', 'c' => 'd']);
=> [ // put() returns the supplied value(s)
"a" => "b",
"c" => "d",
]
>>> tenant()->get('foo');
=> [
"a" => "b",
"c" => "d",
]