From 987c54f04e6ff3bdef068d92da6a9ace847f6c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 15 Feb 2019 21:00:11 +0100 Subject: [PATCH] Fix #29 add Tenancy facade --- README.md | 2 +- composer.json | 5 ++++- src/TenancyFacade.php | 13 +++++++++++++ tests/FacadeTest.php | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/TenancyFacade.php create mode 100644 tests/FacadeTest.php diff --git a/README.md b/README.md index c5f5d5e4..10dade5f 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ Read the [Storage driver](#storage-driver) section for more information. ## Obtaining a `TenantManager` instance -You can use the `tenancy()` and `tenant()` helpers to resolve `Stancl\Tenancy\TenantManager` out of the service container. These two helpers are exactly the same, the only reason there are two is nice syntax. `tenancy()->init()` sounds better than `tenant()->init()` and `tenant()->create()` sounds better than `tenancy()->create()`. +You can use the `tenancy()` and `tenant()` helpers to resolve `Stancl\Tenancy\TenantManager` out of the service container. These two helpers are exactly the same, the only reason there are two is nice syntax. `tenancy()->init()` sounds better than `tenant()->init()` and `tenant()->create()` sounds better than `tenancy()->create()`. **You may also use the `Tenancy` facade.** ### Creating a new tenant diff --git a/composer.json b/composer.json index 1c7a1f1e..748b1b24 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,10 @@ "laravel": { "providers": [ "Stancl\\Tenancy\\TenancyServiceProvider" - ] + ], + "aliases": { + "Tenancy": "Stancl\\Tenancy\\TenancyFacade" + } } } } diff --git a/src/TenancyFacade.php b/src/TenancyFacade.php new file mode 100644 index 00000000..a3c4acdc --- /dev/null +++ b/src/TenancyFacade.php @@ -0,0 +1,13 @@ +put('foo', 'bar'); + Tenancy::put('abc', 'xyz'); + + $this->assertSame('bar', Tenancy::get('foo')); + $this->assertSame('xyz', Tenancy::get('abc')); + } +}