mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 10:14:03 +00:00
2.x update some content
This commit is contained in:
parent
667467ddc4
commit
60d320ad6a
11 changed files with 144 additions and 86 deletions
|
|
@ -7,30 +7,29 @@ section: content
|
|||
|
||||
# Tenant Storage {#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 can use these functions:
|
||||
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:
|
||||
```php
|
||||
get (string|array $key, string $id = null) // $id defaults to the current tenant's id
|
||||
put (string|array $key, mixed $value = null, string $id = null) // if $key is array, make sure $value is null
|
||||
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()`.
|
||||
```php
|
||||
tenancy()->put($key, $value);
|
||||
tenancy()->set($key, $value); // alias for put()
|
||||
tenancy()->put($key, $value, $id);
|
||||
tenancy()->put(['key1' => 'value1', 'key2' => 'value2']);
|
||||
tenancy()->put(['key1' => 'value1', 'key2' => 'value2'], null, $id);
|
||||
$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()`:
|
||||
|
||||
```php
|
||||
tenancy()->get($key);
|
||||
tenancy()->get($key, $id);
|
||||
tenancy()->get(['key1', 'key2']);
|
||||
tenant()->get($key);
|
||||
tenant()->get(['key1', 'key2']);
|
||||
```
|
||||
|
||||
> Note: `tenancy()->get(['key1', 'key2'])` returns an array with values only
|
||||
> 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:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue