1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 21:54:03 +00:00

Add docblocks

This commit is contained in:
lukinovec 2023-04-14 13:04:28 +02:00
parent 411f454aaa
commit a3a1f838e3
11 changed files with 69 additions and 27 deletions

View file

@ -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()}</>";

View file

@ -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 */

View file

@ -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();

View file

@ -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,
) {

View file

@ -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,
) {

View file

@ -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

View file

@ -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,
) {

View file

@ -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,
) {

View file

@ -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
{

View file

@ -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();

View file

@ -92,6 +92,7 @@ class Tenancy
return static::model()->query();
}
/** @return Tenant&Model */
public static function model(): Tenant
{
/** @var class-string<Tenant&Model> $class */