diff --git a/src/helpers.php b/src/helpers.php index 101d43df..3f7f98ab 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -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; } }