mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 14:14:04 +00:00
Fix #29 add Tenancy facade
This commit is contained in:
parent
88d4e67516
commit
987c54f04e
4 changed files with 36 additions and 2 deletions
|
|
@ -133,7 +133,7 @@ Read the [Storage driver](#storage-driver) section for more information.
|
||||||
|
|
||||||
## Obtaining a `TenantManager` instance
|
## 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
|
### Creating a new tenant
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,10 @@
|
||||||
"laravel": {
|
"laravel": {
|
||||||
"providers": [
|
"providers": [
|
||||||
"Stancl\\Tenancy\\TenancyServiceProvider"
|
"Stancl\\Tenancy\\TenancyServiceProvider"
|
||||||
]
|
],
|
||||||
|
"aliases": {
|
||||||
|
"Tenancy": "Stancl\\Tenancy\\TenancyFacade"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
src/TenancyFacade.php
Normal file
13
src/TenancyFacade.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class TenancyFacade extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return TenantManager::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
tests/FacadeTest.php
Normal file
18
tests/FacadeTest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
|
use Stancl\Tenancy\TenancyFacade as Tenancy;
|
||||||
|
|
||||||
|
class FacadeTest extends TestCase
|
||||||
|
{
|
||||||
|
/** @test */
|
||||||
|
public function tenant_manager_can_be_accessed_using_the_Tenancy_facade()
|
||||||
|
{
|
||||||
|
tenancy()->put('foo', 'bar');
|
||||||
|
Tenancy::put('abc', 'xyz');
|
||||||
|
|
||||||
|
$this->assertSame('bar', Tenancy::get('foo'));
|
||||||
|
$this->assertSame('xyz', Tenancy::get('abc'));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue