1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 18:04:03 +00:00

Fix some tests

This commit is contained in:
Samuel Štancl 2019-09-16 17:36:32 +02:00
parent 93d2a281eb
commit 50a77ee826
10 changed files with 76 additions and 61 deletions

View file

@ -6,7 +6,7 @@ namespace Stancl\Tenancy\Facades;
use Illuminate\Support\Facades\Facade;
class GlobalCache extends Facade
class GlobalCacheFacade extends Facade
{
protected static function getFacadeAccessor()
{

View file

@ -7,7 +7,7 @@ namespace Stancl\Tenancy\Facades;
use Illuminate\Support\Facades\Facade;
use Stancl\Tenancy\TenantManager;
class Tenancy extends Facade
class TenancyFacade extends Facade
{
protected static function getFacadeAccessor()
{

View file

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Facades;
use Illuminate\Support\Facades\Facade;
use Stancl\Tenancy\Tenant as Tenant;
class TenantFacade extends Facade
{
protected static function getFacadeAccessor()
{
return Tenant::class;
}
}

View file

@ -77,6 +77,11 @@ class Tenant implements ArrayAccess
return static::new()->withData($data)->persisted(true);
}
public static function create($domains, array $data = []): self
{
return static::new()->withDomains((array) $domains)->withData($data)->save();
}
protected function persisted($persisted = null)
{
if (gettype($persisted) === 'bool') {
@ -132,7 +137,7 @@ class Tenant implements ArrayAccess
return $this;
}
public function withData($data): self
public function withData(array $data): self
{
$this->data = $data;
@ -234,7 +239,7 @@ class Tenant implements ArrayAccess
public function put($key, $value = null): self
{
if ($this->storage->getIdKey() === $key) {
if ($key === 'id') {
throw new TenantStorageException("The tenant's id can't be changed.");
}

View file

@ -22,6 +22,8 @@ if (! \function_exists('tenant')) {
if (! is_null($key)) {
return app(Tenant::class)->get($key);
}
return app(Tenant::class);
}
}