mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:44:02 +00:00
Delete intersection types
This commit is contained in:
parent
82fe91eba2
commit
411f454aaa
12 changed files with 21 additions and 25 deletions
|
|
@ -32,7 +32,7 @@ class TenantList extends Command
|
|||
}
|
||||
|
||||
/** Generate the visual CLI output for the tenant name. */
|
||||
protected function tenantCLI(Model&Tenant $tenant): string
|
||||
protected function tenantCLI(Tenant $tenant): string
|
||||
{
|
||||
return "<fg=yellow>{$tenant->getTenantKeyName()}: {$tenant->getTenantKey()}</>";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ trait HasPending
|
|||
*
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
public static function createPending(array $attributes = []): Model&Tenant
|
||||
public static function createPending(array $attributes = []): Tenant
|
||||
{
|
||||
$tenant = static::create($attributes);
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ trait HasPending
|
|||
}
|
||||
|
||||
/** Pull a pending tenant. */
|
||||
public static function pullPending(): Model&Tenant
|
||||
public static function pullPending(): Tenant
|
||||
{
|
||||
/** @var Model&Tenant $pendingTenant */
|
||||
$pendingTenant = static::pullPendingFromPool(true);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Database;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Database;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -17,7 +16,7 @@ use Stancl\Tenancy\Database\Exceptions\NoConnectionSetException;
|
|||
class DatabaseConfig
|
||||
{
|
||||
/** The tenant whose database we're dealing with. */
|
||||
public Tenant&Model $tenant;
|
||||
public Tenant $tenant;
|
||||
|
||||
/** Database username generator (can be set by the developer.) */
|
||||
public static Closure|null $usernameGenerator = null;
|
||||
|
|
@ -30,20 +29,20 @@ class DatabaseConfig
|
|||
|
||||
public static function __constructStatic(): void
|
||||
{
|
||||
static::$usernameGenerator = static::$usernameGenerator ?? function (Model&Tenant $tenant) {
|
||||
static::$usernameGenerator = static::$usernameGenerator ?? function (Tenant $tenant) {
|
||||
return Str::random(16);
|
||||
};
|
||||
|
||||
static::$passwordGenerator = static::$passwordGenerator ?? function (Model&Tenant $tenant) {
|
||||
static::$passwordGenerator = static::$passwordGenerator ?? function (Tenant $tenant) {
|
||||
return Hash::make(Str::random(32));
|
||||
};
|
||||
|
||||
static::$databaseNameGenerator = static::$databaseNameGenerator ?? function (Model&Tenant $tenant) {
|
||||
static::$databaseNameGenerator = static::$databaseNameGenerator ?? function (Tenant $tenant) {
|
||||
return config('tenancy.database.prefix') . $tenant->getTenantKey() . config('tenancy.database.suffix');
|
||||
};
|
||||
}
|
||||
|
||||
public function __construct(Model&Tenant $tenant)
|
||||
public function __construct(Tenant $tenant)
|
||||
{
|
||||
static::__constructStatic();
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@ use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
|||
|
||||
class SyncedResourceSaved
|
||||
{
|
||||
/** @param Syncable|Model $model */
|
||||
public function __construct(
|
||||
public Syncable&Model $model,
|
||||
public Syncable $model,
|
||||
public TenantWithDatabase|null $tenant,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Jobs;
|
|||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -20,7 +19,7 @@ class CreateDatabase implements ShouldQueue
|
|||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
protected TenantWithDatabase&Model $tenant,
|
||||
protected TenantWithDatabase $tenant,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Jobs;
|
|||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -19,7 +18,7 @@ class DeleteDatabase implements ShouldQueue
|
|||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
protected TenantWithDatabase&Model $tenant,
|
||||
protected TenantWithDatabase $tenant,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -15,9 +14,9 @@ class DeleteDomains
|
|||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected TenantWithDatabase&Model $tenant;
|
||||
protected TenantWithDatabase $tenant;
|
||||
|
||||
public function __construct(TenantWithDatabase&Model $tenant)
|
||||
public function __construct(TenantWithDatabase $tenant)
|
||||
{
|
||||
$this->tenant = $tenant;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Jobs;
|
|||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -18,7 +17,7 @@ class MigrateDatabase implements ShouldQueue
|
|||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
protected TenantWithDatabase&Model $tenant,
|
||||
protected TenantWithDatabase $tenant,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Jobs;
|
|||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
|
@ -18,7 +17,7 @@ class SeedDatabase implements ShouldQueue
|
|||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
protected TenantWithDatabase&Model $tenant,
|
||||
protected TenantWithDatabase $tenant,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,8 @@ class UpdateSyncedResource extends QueueableListener
|
|||
});
|
||||
}
|
||||
|
||||
protected function getAttributesForCreation(Model&Syncable $model): array
|
||||
/** @param Syncable&Model $model */
|
||||
protected function getAttributesForCreation(Syncable $model): array
|
||||
{
|
||||
if (! $model->getSyncedCreationAttributes()) {
|
||||
// Creation attributes are not specified so create the model as 1:1 copy
|
||||
|
|
@ -165,7 +166,7 @@ class UpdateSyncedResource extends QueueableListener
|
|||
/**
|
||||
* Split the attribute names (sequential index items) and default values (key => values).
|
||||
*/
|
||||
protected function getAttributeNamesAndDefaultValues(Model&Syncable $model): array
|
||||
protected function getAttributeNamesAndDefaultValues(Syncable $model): array
|
||||
{
|
||||
$syncedCreationAttributes = $model->getSyncedCreationAttributes() ?? [];
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
|||
/** @var Tenant&Model $tenant */
|
||||
$tenant->unsetRelation('domains');
|
||||
|
||||
return $tenant->domains->map(function (Domain&Model $domain) {
|
||||
return $tenant->domains->map(function (Domain $domain) {
|
||||
return [$domain->domain];
|
||||
})->toArray();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Tenancy
|
|||
return static::model()->query();
|
||||
}
|
||||
|
||||
public static function model(): Tenant&Model
|
||||
public static function model(): Tenant
|
||||
{
|
||||
/** @var class-string<Tenant&Model> $class */
|
||||
$class = config('tenancy.models.tenant');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue