mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
Accept closures in tenant() helper
This commit is contained in:
parent
fd00be646e
commit
a8f84d2808
1 changed files with 13 additions and 4 deletions
|
|
@ -18,14 +18,23 @@ if (! function_exists('tenancy')) {
|
|||
}
|
||||
|
||||
if (! function_exists('tenant')) {
|
||||
/** @return Tenant|mixed */
|
||||
/**
|
||||
* Get a key from the current tenant's storage.
|
||||
*
|
||||
* @param string|Closure|null $key
|
||||
* @return Tenant|mixed
|
||||
*/
|
||||
function tenant($key = null)
|
||||
{
|
||||
if (! is_null($key)) {
|
||||
return optional(app(Tenant::class))->get($key) ?? null;
|
||||
if (is_null($key)) {
|
||||
return app(Tenant::class);
|
||||
}
|
||||
|
||||
return app(Tenant::class);
|
||||
if ($key instanceof Closure) {
|
||||
return app(Tenant::class)->run($key);
|
||||
}
|
||||
|
||||
return optional(app(Tenant::class))->get($key) ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue