mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 00:14:04 +00:00
Fix Travis, add docs for generating HTTPS certificates (#19)
This commit is contained in:
parent
0adbfee86e
commit
6bb18a2b95
8 changed files with 108 additions and 7 deletions
|
|
@ -44,6 +44,11 @@ class DatabaseManager
|
|||
return DB::statement("CREATE DATABASE `$name` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
// todo: delete database. similar to create()
|
||||
}
|
||||
|
||||
public function getDriver(): ?string
|
||||
{
|
||||
return config("database.connections.tenant.driver");
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Route;
|
|||
use Illuminate\Support\ServiceProvider;
|
||||
use Stancl\Tenancy\Commands\TenantList;
|
||||
use Stancl\Tenancy\Interfaces\StorageDriver;
|
||||
use Stancl\Tenancy\Interfaces\ServerConfigManager;
|
||||
use Stancl\Tenancy\StorageDrivers\RedisStorageDriver;
|
||||
|
||||
class TenancyServiceProvider extends ServiceProvider
|
||||
|
|
@ -54,6 +55,7 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
$this->mergeConfigFrom(__DIR__ . '/config/tenancy.php', 'tenancy');
|
||||
|
||||
$this->app->bind(StorageDriver::class, $this->app['config']['tenancy.storage_driver']);
|
||||
$this->app->bind(ServerConfigManager::class, $this->app['config']['tenancy.server.manager']);
|
||||
$this->app->singleton(DatabaseManager::class);
|
||||
$this->app->singleton(TenantManager::class, function ($app) {
|
||||
return new TenantManager($app, $app[StorageDriver::class], $app[DatabaseManager::class]);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Stancl\Tenancy;
|
||||
|
||||
use Stancl\Tenancy\BootstrapsTenancy;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Stancl\Tenancy\Interfaces\StorageDriver;
|
||||
use Stancl\Tenancy\Traits\BootstrapsTenancy;
|
||||
|
||||
class TenantManager
|
||||
{
|
||||
|
|
@ -77,7 +77,7 @@ class TenantManager
|
|||
throw new \Exception("Domain $domain is already occupied by tenant $id.");
|
||||
}
|
||||
|
||||
$tenant = $this->storage->createTenant($domain, \Uuid::generate(1, $domain));
|
||||
$tenant = $this->storage->createTenant($domain, \Webpatser\Uuid\Uuid::generate(1, $domain));
|
||||
$this->database->create($this->getDatabaseName($tenant));
|
||||
|
||||
return $tenant;
|
||||
|
|
@ -264,4 +264,19 @@ class TenantManager
|
|||
|
||||
return $this->put($this->put($key, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the identified tenant's attribute(s).
|
||||
*
|
||||
* @param string $attribute
|
||||
* @return mixed
|
||||
*/
|
||||
public function __invoke($attribute)
|
||||
{
|
||||
if (is_null($attribute)) {
|
||||
return $this->tenant;
|
||||
}
|
||||
|
||||
return $this->tenant[(string) $attribute];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy;
|
||||
namespace Stancl\Tenancy\Traits;
|
||||
|
||||
use Stancl\Tenancy\CacheManager;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
|
||||
trait BootstrapsTenancy
|
||||
{
|
||||
|
|
@ -21,7 +24,6 @@ trait BootstrapsTenancy
|
|||
|
||||
public function setPhpRedisPrefix($connections = ['default'])
|
||||
{
|
||||
return;
|
||||
foreach ($connections as $connection) {
|
||||
$prefix = config('tenancy.redis.prefix_base') . $this->tenant['uuid'];
|
||||
$client = Redis::connection($connection)->client();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue