mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 11:14:04 +00:00
Add docblocks
This commit is contained in:
parent
411f454aaa
commit
a3a1f838e3
11 changed files with 69 additions and 27 deletions
|
|
@ -31,7 +31,11 @@ class TenantList extends Command
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Generate the visual CLI output for the tenant name. */
|
||||
/**
|
||||
* Generate the visual CLI output for the tenant name.
|
||||
*
|
||||
* @param Model&Tenant $tenant
|
||||
*/
|
||||
protected function tenantCLI(Tenant $tenant): string
|
||||
{
|
||||
return "<fg=yellow>{$tenant->getTenantKeyName()}: {$tenant->getTenantKey()}</>";
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ trait HasPending
|
|||
* Create a pending tenant.
|
||||
*
|
||||
* @param array<string, mixed> $attributes
|
||||
* @return Model&Tenant
|
||||
*/
|
||||
public static function createPending(array $attributes = []): Tenant
|
||||
{
|
||||
|
|
@ -63,7 +64,11 @@ trait HasPending
|
|||
return $tenant;
|
||||
}
|
||||
|
||||
/** Pull a pending tenant. */
|
||||
/**
|
||||
* Pull a pending tenant.
|
||||
*
|
||||
* @return Model&Tenant
|
||||
*/
|
||||
public static function pullPending(): Tenant
|
||||
{
|
||||
/** @var Model&Tenant $pendingTenant */
|
||||
|
|
|
|||
|
|
@ -6,16 +6,21 @@ namespace Stancl\Tenancy\Database;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Database;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Stancl\Tenancy\Database\Exceptions\NoConnectionSetException;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase as Tenant;
|
||||
use Stancl\Tenancy\Database\Exceptions\DatabaseManagerNotRegisteredException;
|
||||
use Stancl\Tenancy\Database\Exceptions\NoConnectionSetException;
|
||||
|
||||
class DatabaseConfig
|
||||
{
|
||||
/** The tenant whose database we're dealing with. */
|
||||
/**
|
||||
* The tenant whose database we're dealing with.
|
||||
*
|
||||
* @var Tenant&Model $tenant
|
||||
*/
|
||||
public Tenant $tenant;
|
||||
|
||||
/** Database username generator (can be set by the developer.) */
|
||||
|
|
@ -29,19 +34,23 @@ class DatabaseConfig
|
|||
|
||||
public static function __constructStatic(): void
|
||||
{
|
||||
/** @param Model&Tenant $tenant */
|
||||
static::$usernameGenerator = static::$usernameGenerator ?? function (Tenant $tenant) {
|
||||
return Str::random(16);
|
||||
};
|
||||
|
||||
/** @param Model&Tenant $tenant */
|
||||
static::$passwordGenerator = static::$passwordGenerator ?? function (Tenant $tenant) {
|
||||
return Hash::make(Str::random(32));
|
||||
};
|
||||
|
||||
/** @param Model&Tenant $tenant */
|
||||
static::$databaseNameGenerator = static::$databaseNameGenerator ?? function (Tenant $tenant) {
|
||||
return config('tenancy.database.prefix') . $tenant->getTenantKey() . config('tenancy.database.suffix');
|
||||
};
|
||||
}
|
||||
|
||||
/** @param Model&Tenant $tenant */
|
||||
public function __construct(Tenant $tenant)
|
||||
{
|
||||
static::__constructStatic();
|
||||
|
|
|
|||
|
|
@ -5,19 +5,21 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Stancl\Tenancy\Events\DatabaseCreated;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
use Stancl\Tenancy\Database\DatabaseManager;
|
||||
use Stancl\Tenancy\Events\CreatingDatabase;
|
||||
use Stancl\Tenancy\Events\DatabaseCreated;
|
||||
use Stancl\Tenancy\Database\DatabaseManager;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class CreateDatabase implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @param TenantWithDatabase&Model $tenant */
|
||||
public function __construct(
|
||||
protected TenantWithDatabase $tenant,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -5,18 +5,23 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Stancl\Tenancy\Events\DatabaseDeleted;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
use Stancl\Tenancy\Events\DatabaseDeleted;
|
||||
use Stancl\Tenancy\Events\DeletingDatabase;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class DeleteDatabase implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var TenantWithDatabase&Model $tenant
|
||||
* @param TenantWithDatabase&Model $tenant
|
||||
*/
|
||||
public function __construct(
|
||||
protected TenantWithDatabase $tenant,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -5,20 +5,23 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class DeleteDomains
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected TenantWithDatabase $tenant;
|
||||
|
||||
public function __construct(TenantWithDatabase $tenant)
|
||||
{
|
||||
$this->tenant = $tenant;
|
||||
/**
|
||||
* @var TenantWithDatabase&Model $tenant
|
||||
* @param TenantWithDatabase&Model $tenant
|
||||
*/
|
||||
public function __construct(
|
||||
protected TenantWithDatabase $tenant
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
|
|
|
|||
|
|
@ -5,17 +5,22 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class MigrateDatabase implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var TenantWithDatabase&Model $tenant
|
||||
* @param TenantWithDatabase&Model $tenant
|
||||
*/
|
||||
public function __construct(
|
||||
protected TenantWithDatabase $tenant,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -5,17 +5,22 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class SeedDatabase implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var TenantWithDatabase&Model $tenant
|
||||
* @param TenantWithDatabase&Model $tenant
|
||||
*/
|
||||
public function __construct(
|
||||
protected TenantWithDatabase $tenant,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -165,6 +165,8 @@ class UpdateSyncedResource extends QueueableListener
|
|||
|
||||
/**
|
||||
* Split the attribute names (sequential index items) and default values (key => values).
|
||||
*
|
||||
* @param Model&Syncable $model
|
||||
*/
|
||||
protected function getAttributeNamesAndDefaultValues(Syncable $model): array
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
|||
/** @var Tenant&Model $tenant */
|
||||
$tenant->unsetRelation('domains');
|
||||
|
||||
/** @param Domain&Model $domain */
|
||||
return $tenant->domains->map(function (Domain $domain) {
|
||||
return [$domain->domain];
|
||||
})->toArray();
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ class Tenancy
|
|||
return static::model()->query();
|
||||
}
|
||||
|
||||
/** @return Tenant&Model */
|
||||
public static function model(): Tenant
|
||||
{
|
||||
/** @var class-string<Tenant&Model> $class */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue