mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:54: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) {
|
||||
$finalPrefix = $originalRoot
|
||||
? rtrim($originalRoot, '/') . '/'. $suffix
|
||||
? rtrim($originalRoot, '/') . '/' . $suffix
|
||||
: $suffix;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,18 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy\Bootstrappers;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Config\Repository;
|
||||
use Illuminate\Queue\QueueManager;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Queue\Events\JobFailed;
|
||||
use Illuminate\Queue\Events\JobProcessed;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Queue\Events\JobRetryRequested;
|
||||
use Illuminate\Queue\QueueManager;
|
||||
use Illuminate\Support\Testing\Fakes\QueueFake;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
|
||||
class QueueTenancyBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class CacheManager extends BaseCacheManager
|
|||
|
||||
if ($method === 'tags') {
|
||||
$count = count($parameters);
|
||||
|
||||
|
||||
if ($count !== 1) {
|
||||
throw new \Exception("Method tags() takes exactly 1 argument. $count passed.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,9 @@ class TenantDump extends DumpCommand
|
|||
$this->specifyParameters();
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Concerns;
|
||||
|
||||
trait ExtendsLaravelCommand
|
||||
|
|
|
|||
|
|
@ -22,10 +22,15 @@ class ImpersonationToken extends Model
|
|||
use CentralConnection;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $primaryKey = 'token';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $table = 'tenant_user_impersonation_tokens';
|
||||
|
||||
protected $dates = [
|
||||
'created_at',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ class Tenant extends Model implements Contracts\Tenant
|
|||
Concerns\InvalidatesResolverCache;
|
||||
|
||||
protected $table = 'tenants';
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function getTenantKeyName(): string
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ class UpdateSyncedResource extends QueueableListener
|
|||
protected function updateResourceInCentralDatabaseAndGetTenants($event, $syncedAttributes)
|
||||
{
|
||||
/** @var Model|SyncMaster $centralModel */
|
||||
$centralModel = $event->model->getCentralModelName()
|
||||
::where($event->model->getGlobalIdentifierKeyName(), $event->model->getGlobalIdentifierKey())
|
||||
$centralModel = $event->model->getCentralModelName()::where($event->model->getGlobalIdentifierKeyName(), $event->model->getGlobalIdentifierKey())
|
||||
->first();
|
||||
|
||||
// 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;
|
||||
|
||||
use Closure;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
|
||||
use Stancl\Tenancy\Exceptions\TenancyNotInitializedException;
|
||||
use Symfony\Component\HttpFoundation\IpUtils;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class CheckTenantForMaintenanceMode extends CheckForMaintenanceMode
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,26 +5,26 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Tests;
|
||||
|
||||
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\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Stancl\Tenancy\Events\TenancyEnded;
|
||||
use Stancl\Tenancy\Jobs\CreateDatabase;
|
||||
use Stancl\Tenancy\Events\TenantCreated;
|
||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||
use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
||||
use Illuminate\Support\Str;
|
||||
use ReflectionObject;
|
||||
use ReflectionProperty;
|
||||
use Stancl\JobPipeline\JobPipeline;
|
||||
use Stancl\Tenancy\Bootstrappers\CacheTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
||||
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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class ExampleSeeder extends Seeder
|
|||
{
|
||||
DB::table('users')->insert([
|
||||
'name' => Str::random(10),
|
||||
'email' => Str::random(10).'@gmail.com',
|
||||
'email' => Str::random(10) . '@gmail.com',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ use Stancl\Tenancy\Jobs\CreateDatabase;
|
|||
use Stancl\Tenancy\Jobs\MigrateDatabase;
|
||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||
use Stancl\Tenancy\Listeners\QueueableListener;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
|
||||
class EventListenerTest extends TestCase
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy\Tests;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Stancl\Tenancy\Database\Concerns\MaintenanceMode;
|
||||
use Stancl\Tenancy\Middleware\CheckTenantForMaintenanceMode;
|
||||
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class MaintenanceModeTest extends TestCase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,33 +4,31 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy\Tests;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Spatie\Valuestore\Valuestore;
|
||||
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\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\Events\JobProcessed;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use PDO;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
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\TenantCreated;
|
||||
use Stancl\Tenancy\Jobs\CreateDatabase;
|
||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||
use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
||||
use Stancl\Tenancy\Bootstrappers\QueueTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Stancl\Tenancy\Tests\Etc\User;
|
||||
|
||||
class QueueTest extends TestCase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -589,7 +589,9 @@ class CentralUser extends Model implements SyncMaster
|
|||
use ResourceSyncing, CentralConnection;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public $table = 'users';
|
||||
|
||||
public function tenants(): BelongsToMany
|
||||
|
|
@ -633,7 +635,9 @@ class ResourceUser extends Model implements Syncable
|
|||
use ResourceSyncing;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function getGlobalIdentifierKey()
|
||||
|
|
|
|||
|
|
@ -329,6 +329,7 @@ class Post extends Model
|
|||
use BelongsToTenant;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function comments()
|
||||
|
|
@ -345,6 +346,7 @@ class Post extends Model
|
|||
class Comment extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function post()
|
||||
|
|
@ -368,5 +370,6 @@ class ScopedComment extends Comment
|
|||
class GlobalResource extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class TenantDatabaseManagerTest extends TestCase
|
|||
['sqlite', SQLiteDatabaseManager::class],
|
||||
['pgsql', PostgreSQLDatabaseManager::class],
|
||||
['pgsql', PostgreSQLSchemaManager::class],
|
||||
['sqlsrv', MicrosoftSQLDatabaseManager::class]
|
||||
['sqlsrv', MicrosoftSQLDatabaseManager::class],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ class TenantDatabaseManagerTest extends TestCase
|
|||
]);
|
||||
tenancy()->initialize($tenant);
|
||||
|
||||
$schemaConfig = version_compare(app()->version(), '9.0', '>=') ?
|
||||
$schemaConfig = version_compare(app()->version(), '9.0', '>=') ?
|
||||
config('database.connections.' . config('database.default') . '.search_path') :
|
||||
config('database.connections.' . config('database.default') . '.schema');
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ class MyTenant extends Tenant
|
|||
class AnotherTenant extends Model implements Contracts\Tenant
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected $table = 'tenants';
|
||||
|
||||
public function getTenantKeyName(): string
|
||||
|
|
|
|||
|
|
@ -274,11 +274,13 @@ class TenantUserImpersonationTest extends TestCase
|
|||
class ImpersonationUser extends Authenticable
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected $table = 'users';
|
||||
}
|
||||
|
||||
class AnotherImpersonationUser extends Authenticable
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected $table = 'users';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue