mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 08:24:03 +00:00
Fix styling
This commit is contained in:
parent
f498daacc2
commit
c9ab5c4f1d
19 changed files with 62 additions and 51 deletions
|
|
@ -69,7 +69,7 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
|
|
||||||
if (! $finalPrefix) {
|
if (! $finalPrefix) {
|
||||||
$finalPrefix = $originalRoot
|
$finalPrefix = $originalRoot
|
||||||
? rtrim($originalRoot, '/') . '/'. $suffix
|
? rtrim($originalRoot, '/') . '/' . $suffix
|
||||||
: $suffix;
|
: $suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,17 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Bootstrappers;
|
namespace Stancl\Tenancy\Bootstrappers;
|
||||||
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Config\Repository;
|
use Illuminate\Config\Repository;
|
||||||
use Illuminate\Queue\QueueManager;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
use Stancl\Tenancy\Contracts\Tenant;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Queue\Events\JobFailed;
|
use Illuminate\Queue\Events\JobFailed;
|
||||||
use Illuminate\Queue\Events\JobProcessed;
|
use Illuminate\Queue\Events\JobProcessed;
|
||||||
use Illuminate\Queue\Events\JobProcessing;
|
use Illuminate\Queue\Events\JobProcessing;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
|
||||||
use Illuminate\Queue\Events\JobRetryRequested;
|
use Illuminate\Queue\Events\JobRetryRequested;
|
||||||
|
use Illuminate\Queue\QueueManager;
|
||||||
use Illuminate\Support\Testing\Fakes\QueueFake;
|
use Illuminate\Support\Testing\Fakes\QueueFake;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
|
||||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||||
|
use Stancl\Tenancy\Contracts\Tenant;
|
||||||
|
|
||||||
class QueueTenancyBootstrapper implements TenancyBootstrapper
|
class QueueTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,9 @@ class TenantDump extends DumpCommand
|
||||||
$this->specifyParameters();
|
$this->specifyParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function handle(ConnectionResolverInterface $connections, Dispatcher $dispatcher): int
|
public function handle(ConnectionResolverInterface $connections, Dispatcher $dispatcher): int
|
||||||
{
|
{
|
||||||
$this->tenant()->run(fn() => parent::handle($connections, $dispatcher));
|
$this->tenant()->run(fn () => parent::handle($connections, $dispatcher));
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Concerns;
|
namespace Stancl\Tenancy\Concerns;
|
||||||
|
|
||||||
trait ExtendsLaravelCommand
|
trait ExtendsLaravelCommand
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,15 @@ class ImpersonationToken extends Model
|
||||||
use CentralConnection;
|
use CentralConnection;
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
protected $primaryKey = 'token';
|
protected $primaryKey = 'token';
|
||||||
|
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
protected $table = 'tenant_user_impersonation_tokens';
|
protected $table = 'tenant_user_impersonation_tokens';
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
'created_at',
|
'created_at',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,9 @@ class Tenant extends Model implements Contracts\Tenant
|
||||||
Concerns\InvalidatesResolverCache;
|
Concerns\InvalidatesResolverCache;
|
||||||
|
|
||||||
protected $table = 'tenants';
|
protected $table = 'tenants';
|
||||||
|
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
public function getTenantKeyName(): string
|
public function getTenantKeyName(): string
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,7 @@ class UpdateSyncedResource extends QueueableListener
|
||||||
protected function updateResourceInCentralDatabaseAndGetTenants($event, $syncedAttributes)
|
protected function updateResourceInCentralDatabaseAndGetTenants($event, $syncedAttributes)
|
||||||
{
|
{
|
||||||
/** @var Model|SyncMaster $centralModel */
|
/** @var Model|SyncMaster $centralModel */
|
||||||
$centralModel = $event->model->getCentralModelName()
|
$centralModel = $event->model->getCentralModelName()::where($event->model->getGlobalIdentifierKeyName(), $event->model->getGlobalIdentifierKey())
|
||||||
::where($event->model->getGlobalIdentifierKeyName(), $event->model->getGlobalIdentifierKey())
|
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
// We disable events for this call, to avoid triggering this event & listener again.
|
// We disable events for this call, to avoid triggering this event & listener again.
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||||
namespace Stancl\Tenancy\Middleware;
|
namespace Stancl\Tenancy\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
||||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
|
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
|
||||||
use Stancl\Tenancy\Exceptions\TenancyNotInitializedException;
|
use Stancl\Tenancy\Exceptions\TenancyNotInitializedException;
|
||||||
use Symfony\Component\HttpFoundation\IpUtils;
|
use Symfony\Component\HttpFoundation\IpUtils;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
class CheckTenantForMaintenanceMode extends CheckForMaintenanceMode
|
class CheckTenantForMaintenanceMode extends CheckForMaintenanceMode
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,26 +5,26 @@ declare(strict_types=1);
|
||||||
namespace Stancl\Tenancy\Tests;
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
use Illuminate\Filesystem\FilesystemAdapter;
|
use Illuminate\Filesystem\FilesystemAdapter;
|
||||||
use ReflectionObject;
|
|
||||||
use ReflectionProperty;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Stancl\JobPipeline\JobPipeline;
|
|
||||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Illuminate\Support\Facades\Redis;
|
use Illuminate\Support\Facades\Redis;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Stancl\Tenancy\Events\TenancyEnded;
|
use Illuminate\Support\Str;
|
||||||
use Stancl\Tenancy\Jobs\CreateDatabase;
|
use ReflectionObject;
|
||||||
use Stancl\Tenancy\Events\TenantCreated;
|
use ReflectionProperty;
|
||||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
use Stancl\JobPipeline\JobPipeline;
|
||||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
|
||||||
use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
|
||||||
use Stancl\Tenancy\Bootstrappers\CacheTenancyBootstrapper;
|
use Stancl\Tenancy\Bootstrappers\CacheTenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
|
|
||||||
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||||
|
use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
|
||||||
|
use Stancl\Tenancy\Events\TenancyEnded;
|
||||||
|
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||||
|
use Stancl\Tenancy\Events\TenantCreated;
|
||||||
|
use Stancl\Tenancy\Jobs\CreateDatabase;
|
||||||
|
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||||
|
use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
||||||
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||||
|
|
||||||
class BootstrapperTest extends TestCase
|
class BootstrapperTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class ExampleSeeder extends Seeder
|
||||||
{
|
{
|
||||||
DB::table('users')->insert([
|
DB::table('users')->insert([
|
||||||
'name' => Str::random(10),
|
'name' => Str::random(10),
|
||||||
'email' => Str::random(10).'@gmail.com',
|
'email' => Str::random(10) . '@gmail.com',
|
||||||
'password' => bcrypt('password'),
|
'password' => bcrypt('password'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ use Stancl\Tenancy\Jobs\CreateDatabase;
|
||||||
use Stancl\Tenancy\Jobs\MigrateDatabase;
|
use Stancl\Tenancy\Jobs\MigrateDatabase;
|
||||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||||
use Stancl\Tenancy\Listeners\QueueableListener;
|
use Stancl\Tenancy\Listeners\QueueableListener;
|
||||||
use Stancl\Tenancy\Tenancy;
|
|
||||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||||
|
|
||||||
class EventListenerTest extends TestCase
|
class EventListenerTest extends TestCase
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Tests;
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
||||||
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Stancl\Tenancy\Database\Concerns\MaintenanceMode;
|
use Stancl\Tenancy\Database\Concerns\MaintenanceMode;
|
||||||
use Stancl\Tenancy\Middleware\CheckTenantForMaintenanceMode;
|
use Stancl\Tenancy\Middleware\CheckTenantForMaintenanceMode;
|
||||||
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
|
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
|
||||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
class MaintenanceModeTest extends TestCase
|
class MaintenanceModeTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,33 +4,31 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Tests;
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Spatie\Valuestore\Valuestore;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Stancl\Tenancy\Tests\Etc\User;
|
|
||||||
use Stancl\JobPipeline\JobPipeline;
|
|
||||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
|
||||||
use Illuminate\Support\Facades\Event;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Stancl\Tenancy\Events\TenancyEnded;
|
|
||||||
use Stancl\Tenancy\Jobs\CreateDatabase;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Stancl\Tenancy\Events\TenantCreated;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\Events\JobProcessed;
|
use Illuminate\Queue\Events\JobProcessed;
|
||||||
use Illuminate\Queue\Events\JobProcessing;
|
use Illuminate\Queue\Events\JobProcessing;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use PDO;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Spatie\Valuestore\Valuestore;
|
||||||
|
use Stancl\JobPipeline\JobPipeline;
|
||||||
|
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
||||||
|
use Stancl\Tenancy\Bootstrappers\QueueTenancyBootstrapper;
|
||||||
|
use Stancl\Tenancy\Events\TenancyEnded;
|
||||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||||
|
use Stancl\Tenancy\Events\TenantCreated;
|
||||||
|
use Stancl\Tenancy\Jobs\CreateDatabase;
|
||||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||||
use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
||||||
use Stancl\Tenancy\Bootstrappers\QueueTenancyBootstrapper;
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||||
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
use Stancl\Tenancy\Tests\Etc\User;
|
||||||
|
|
||||||
class QueueTest extends TestCase
|
class QueueTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -589,7 +589,9 @@ class CentralUser extends Model implements SyncMaster
|
||||||
use ResourceSyncing, CentralConnection;
|
use ResourceSyncing, CentralConnection;
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
public $table = 'users';
|
public $table = 'users';
|
||||||
|
|
||||||
public function tenants(): BelongsToMany
|
public function tenants(): BelongsToMany
|
||||||
|
|
@ -633,7 +635,9 @@ class ResourceUser extends Model implements Syncable
|
||||||
use ResourceSyncing;
|
use ResourceSyncing;
|
||||||
|
|
||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
public function getGlobalIdentifierKey()
|
public function getGlobalIdentifierKey()
|
||||||
|
|
|
||||||
|
|
@ -329,6 +329,7 @@ class Post extends Model
|
||||||
use BelongsToTenant;
|
use BelongsToTenant;
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
public function comments()
|
public function comments()
|
||||||
|
|
@ -345,6 +346,7 @@ class Post extends Model
|
||||||
class Comment extends Model
|
class Comment extends Model
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
public function post()
|
public function post()
|
||||||
|
|
@ -368,5 +370,6 @@ class ScopedComment extends Comment
|
||||||
class GlobalResource extends Model
|
class GlobalResource extends Model
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ class TenantDatabaseManagerTest extends TestCase
|
||||||
['sqlite', SQLiteDatabaseManager::class],
|
['sqlite', SQLiteDatabaseManager::class],
|
||||||
['pgsql', PostgreSQLDatabaseManager::class],
|
['pgsql', PostgreSQLDatabaseManager::class],
|
||||||
['pgsql', PostgreSQLSchemaManager::class],
|
['pgsql', PostgreSQLSchemaManager::class],
|
||||||
['sqlsrv', MicrosoftSQLDatabaseManager::class]
|
['sqlsrv', MicrosoftSQLDatabaseManager::class],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ class MyTenant extends Tenant
|
||||||
class AnotherTenant extends Model implements Contracts\Tenant
|
class AnotherTenant extends Model implements Contracts\Tenant
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
protected $table = 'tenants';
|
protected $table = 'tenants';
|
||||||
|
|
||||||
public function getTenantKeyName(): string
|
public function getTenantKeyName(): string
|
||||||
|
|
|
||||||
|
|
@ -274,11 +274,13 @@ class TenantUserImpersonationTest extends TestCase
|
||||||
class ImpersonationUser extends Authenticable
|
class ImpersonationUser extends Authenticable
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnotherImpersonationUser extends Authenticable
|
class AnotherImpersonationUser extends Authenticable
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue