Always prefer ::class notation

This commit is contained in:
Lucas Michot
2024-10-28 14:56:13 +01:00
parent 94e73c6d8b
commit c5403b0b3f
31 changed files with 99 additions and 99 deletions

View File

@@ -23,28 +23,28 @@ class StartDatabase
return 'Server is not functional'; return 'Server is not functional';
} }
switch ($database->getMorphClass()) { switch ($database->getMorphClass()) {
case 'App\Models\StandalonePostgresql': case \App\Models\StandalonePostgresql::class:
$activity = StartPostgresql::run($database); $activity = StartPostgresql::run($database);
break; break;
case 'App\Models\StandaloneRedis': case \App\Models\StandaloneRedis::class:
$activity = StartRedis::run($database); $activity = StartRedis::run($database);
break; break;
case 'App\Models\StandaloneMongodb': case \App\Models\StandaloneMongodb::class:
$activity = StartMongodb::run($database); $activity = StartMongodb::run($database);
break; break;
case 'App\Models\StandaloneMysql': case \App\Models\StandaloneMysql::class:
$activity = StartMysql::run($database); $activity = StartMysql::run($database);
break; break;
case 'App\Models\StandaloneMariadb': case \App\Models\StandaloneMariadb::class:
$activity = StartMariadb::run($database); $activity = StartMariadb::run($database);
break; break;
case 'App\Models\StandaloneKeydb': case \App\Models\StandaloneKeydb::class:
$activity = StartKeydb::run($database); $activity = StartKeydb::run($database);
break; break;
case 'App\Models\StandaloneDragonfly': case \App\Models\StandaloneDragonfly::class:
$activity = StartDragonfly::run($database); $activity = StartDragonfly::run($database);
break; break;
case 'App\Models\StandaloneClickhouse': case \App\Models\StandaloneClickhouse::class:
$activity = StartClickhouse::run($database); $activity = StartClickhouse::run($database);
break; break;
} }

View File

@@ -26,7 +26,7 @@ class StartDatabaseProxy
$server = data_get($database, 'destination.server'); $server = data_get($database, 'destination.server');
$containerName = data_get($database, 'uuid'); $containerName = data_get($database, 'uuid');
$proxyContainerName = "{$database->uuid}-proxy"; $proxyContainerName = "{$database->uuid}-proxy";
if ($database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($database->getMorphClass() === \App\Models\ServiceDatabase::class) {
$databaseType = $database->databaseType(); $databaseType = $database->databaseType();
// $connectPredefined = data_get($database, 'service.connect_to_docker_network'); // $connectPredefined = data_get($database, 'service.connect_to_docker_network');
$network = $database->service->uuid; $network = $database->service->uuid;
@@ -34,54 +34,54 @@ class StartDatabaseProxy
$proxyContainerName = "{$database->service->uuid}-proxy"; $proxyContainerName = "{$database->service->uuid}-proxy";
switch ($databaseType) { switch ($databaseType) {
case 'standalone-mariadb': case 'standalone-mariadb':
$type = 'App\Models\StandaloneMariadb'; $type = \App\Models\StandaloneMariadb::class;
$containerName = "mariadb-{$database->service->uuid}"; $containerName = "mariadb-{$database->service->uuid}";
break; break;
case 'standalone-mongodb': case 'standalone-mongodb':
$type = 'App\Models\StandaloneMongodb'; $type = \App\Models\StandaloneMongodb::class;
$containerName = "mongodb-{$database->service->uuid}"; $containerName = "mongodb-{$database->service->uuid}";
break; break;
case 'standalone-mysql': case 'standalone-mysql':
$type = 'App\Models\StandaloneMysql'; $type = \App\Models\StandaloneMysql::class;
$containerName = "mysql-{$database->service->uuid}"; $containerName = "mysql-{$database->service->uuid}";
break; break;
case 'standalone-postgresql': case 'standalone-postgresql':
$type = 'App\Models\StandalonePostgresql'; $type = \App\Models\StandalonePostgresql::class;
$containerName = "postgresql-{$database->service->uuid}"; $containerName = "postgresql-{$database->service->uuid}";
break; break;
case 'standalone-redis': case 'standalone-redis':
$type = 'App\Models\StandaloneRedis'; $type = \App\Models\StandaloneRedis::class;
$containerName = "redis-{$database->service->uuid}"; $containerName = "redis-{$database->service->uuid}";
break; break;
case 'standalone-keydb': case 'standalone-keydb':
$type = 'App\Models\StandaloneKeydb'; $type = \App\Models\StandaloneKeydb::class;
$containerName = "keydb-{$database->service->uuid}"; $containerName = "keydb-{$database->service->uuid}";
break; break;
case 'standalone-dragonfly': case 'standalone-dragonfly':
$type = 'App\Models\StandaloneDragonfly'; $type = \App\Models\StandaloneDragonfly::class;
$containerName = "dragonfly-{$database->service->uuid}"; $containerName = "dragonfly-{$database->service->uuid}";
break; break;
case 'standalone-clickhouse': case 'standalone-clickhouse':
$type = 'App\Models\StandaloneClickhouse'; $type = \App\Models\StandaloneClickhouse::class;
$containerName = "clickhouse-{$database->service->uuid}"; $containerName = "clickhouse-{$database->service->uuid}";
break; break;
} }
} }
if ($type === 'App\Models\StandaloneRedis') { if ($type === \App\Models\StandaloneRedis::class) {
$internalPort = 6379; $internalPort = 6379;
} elseif ($type === 'App\Models\StandalonePostgresql') { } elseif ($type === \App\Models\StandalonePostgresql::class) {
$internalPort = 5432; $internalPort = 5432;
} elseif ($type === 'App\Models\StandaloneMongodb') { } elseif ($type === \App\Models\StandaloneMongodb::class) {
$internalPort = 27017; $internalPort = 27017;
} elseif ($type === 'App\Models\StandaloneMysql') { } elseif ($type === \App\Models\StandaloneMysql::class) {
$internalPort = 3306; $internalPort = 3306;
} elseif ($type === 'App\Models\StandaloneMariadb') { } elseif ($type === \App\Models\StandaloneMariadb::class) {
$internalPort = 3306; $internalPort = 3306;
} elseif ($type === 'App\Models\StandaloneKeydb') { } elseif ($type === \App\Models\StandaloneKeydb::class) {
$internalPort = 6379; $internalPort = 6379;
} elseif ($type === 'App\Models\StandaloneDragonfly') { } elseif ($type === \App\Models\StandaloneDragonfly::class) {
$internalPort = 6379; $internalPort = 6379;
} elseif ($type === 'App\Models\StandaloneClickhouse') { } elseif ($type === \App\Models\StandaloneClickhouse::class) {
$internalPort = 9000; $internalPort = 9000;
} }
$configuration_dir = database_proxy_dir($database->uuid); $configuration_dir = database_proxy_dir($database->uuid);

View File

@@ -22,7 +22,7 @@ class StopDatabaseProxy
{ {
$server = data_get($database, 'destination.server'); $server = data_get($database, 'destination.server');
$uuid = $database->uuid; $uuid = $database->uuid;
if ($database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($database->getMorphClass() === \App\Models\ServiceDatabase::class) {
$uuid = $database->service->uuid; $uuid = $database->service->uuid;
$server = data_get($database, 'service.server'); $server = data_get($database, 'service.server');
} }

View File

@@ -180,7 +180,7 @@ class Init extends Command
'save_s3' => false, 'save_s3' => false,
'frequency' => '0 0 * * *', 'frequency' => '0 0 * * *',
'database_id' => $database->id, 'database_id' => $database->id,
'database_type' => 'App\Models\StandalonePostgresql', 'database_type' => \App\Models\StandalonePostgresql::class,
'team_id' => 0, 'team_id' => 0,
]); ]);
} }

View File

@@ -292,7 +292,7 @@ class DeployController extends Controller
return ['message' => "Resource ($resource) not found.", 'deployment_uuid' => $deployment_uuid]; return ['message' => "Resource ($resource) not found.", 'deployment_uuid' => $deployment_uuid];
} }
switch ($resource?->getMorphClass()) { switch ($resource?->getMorphClass()) {
case 'App\Models\Application': case \App\Models\Application::class:
$deployment_uuid = new Cuid2; $deployment_uuid = new Cuid2;
queue_application_deployment( queue_application_deployment(
application: $resource, application: $resource,
@@ -301,7 +301,7 @@ class DeployController extends Controller
); );
$message = "Application {$resource->name} deployment queued."; $message = "Application {$resource->name} deployment queued.";
break; break;
case 'App\Models\Service': case \App\Models\Service::class:
StartService::run($resource); StartService::run($resource);
$message = "Service {$resource->name} started. It could take a while, be patient."; $message = "Service {$resource->name} started. It could take a while, be patient.";
break; break;

View File

@@ -53,7 +53,7 @@ class ResourcesController extends Controller
$resources = $resources->flatten(); $resources = $resources->flatten();
$resources = $resources->map(function ($resource) { $resources = $resources->map(function ($resource) {
$payload = $resource->toArray(); $payload = $resource->toArray();
if ($resource->getMorphClass() === 'App\Models\Service') { if ($resource->getMorphClass() === \App\Models\Service::class) {
$payload['status'] = $resource->status(); $payload['status'] = $resource->status();
} else { } else {
$payload['status'] = $resource->status; $payload['status'] = $resource->status;

View File

@@ -72,7 +72,7 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
return; return;
} }
if (data_get($this->backup, 'database_type') === 'App\Models\ServiceDatabase') { if (data_get($this->backup, 'database_type') === \App\Models\ServiceDatabase::class) {
$this->database = data_get($this->backup, 'database'); $this->database = data_get($this->backup, 'database');
$this->server = $this->database->service->server; $this->server = $this->database->service->server;
$this->s3 = $this->backup->s3; $this->s3 = $this->backup->s3;
@@ -94,7 +94,7 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
if (! $status->startsWith('running') && $this->database->id !== 0) { if (! $status->startsWith('running') && $this->database->id !== 0) {
return; return;
} }
if (data_get($this->backup, 'database_type') === 'App\Models\ServiceDatabase') { if (data_get($this->backup, 'database_type') === \App\Models\ServiceDatabase::class) {
$databaseType = $this->database->databaseType(); $databaseType = $this->database->databaseType();
$serviceUuid = $this->database->service->uuid; $serviceUuid = $this->database->service->uuid;
$serviceName = str($this->database->service->name)->slug(); $serviceName = str($this->database->service->name)->slug();
@@ -484,7 +484,7 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
$bucket = $this->s3->bucket; $bucket = $this->s3->bucket;
$endpoint = $this->s3->endpoint; $endpoint = $this->s3->endpoint;
$this->s3->testConnection(shouldSave: true); $this->s3->testConnection(shouldSave: true);
if (data_get($this->backup, 'database_type') === 'App\Models\ServiceDatabase') { if (data_get($this->backup, 'database_type') === \App\Models\ServiceDatabase::class) {
$network = $this->database->service->destination->network; $network = $this->database->service->destination->network;
} else { } else {
$network = $this->database->destination->network; $network = $this->database->destination->network;

View File

@@ -29,7 +29,7 @@ class Form extends Component
public function delete() public function delete()
{ {
try { try {
if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') { if ($this->destination->getMorphClass() === \App\Models\StandaloneDocker::class) {
if ($this->destination->attachedTo()) { if ($this->destination->attachedTo()) {
return $this->dispatch('error', 'You must delete all resources before deleting this destination.'); return $this->dispatch('error', 'You must delete all resources before deleting this destination.');
} }

View File

@@ -24,10 +24,10 @@ class Index extends Component
} }
// No backups // No backups
if ( if (
$database->getMorphClass() === 'App\Models\StandaloneRedis' || $database->getMorphClass() === \App\Models\StandaloneRedis::class ||
$database->getMorphClass() === 'App\Models\StandaloneKeydb' || $database->getMorphClass() === \App\Models\StandaloneKeydb::class ||
$database->getMorphClass() === 'App\Models\StandaloneDragonfly' || $database->getMorphClass() === \App\Models\StandaloneDragonfly::class ||
$database->getMorphClass() === 'App\Models\StandaloneClickhouse' $database->getMorphClass() === \App\Models\StandaloneClickhouse::class
) { ) {
return redirect()->route('project.database.configuration', [ return redirect()->route('project.database.configuration', [
'project_uuid' => $project->uuid, 'project_uuid' => $project->uuid,

View File

@@ -77,7 +77,7 @@ class BackupEdit extends Component
$this->backup->delete(); $this->backup->delete();
if ($this->backup->database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($this->backup->database->getMorphClass() === \App\Models\ServiceDatabase::class) {
$previousUrl = url()->previous(); $previousUrl = url()->previous();
$url = Url::fromString($previousUrl); $url = Url::fromString($previousUrl);
$url = $url->withoutQueryParameter('selectedBackupId'); $url = $url->withoutQueryParameter('selectedBackupId');
@@ -138,7 +138,7 @@ class BackupEdit extends Component
$backupFolder = null; $backupFolder = null;
foreach ($executions as $execution) { foreach ($executions as $execution) {
if ($this->backup->database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($this->backup->database->getMorphClass() === \App\Models\ServiceDatabase::class) {
$server = $this->backup->database->service->destination->server; $server = $this->backup->database->service->destination->server;
} else { } else {
$server = $this->backup->database->destination->server; $server = $this->backup->database->destination->server;

View File

@@ -57,7 +57,7 @@ class BackupExecutions extends Component
return; return;
} }
if ($execution->scheduledDatabaseBackup->database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($execution->scheduledDatabaseBackup->database->getMorphClass() === \App\Models\ServiceDatabase::class) {
delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->service->destination->server); delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->service->destination->server);
} else { } else {
delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->destination->server); delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->destination->server);

View File

@@ -66,7 +66,7 @@ class CreateScheduledBackup extends Component
} }
$databaseBackup = ScheduledDatabaseBackup::create($payload); $databaseBackup = ScheduledDatabaseBackup::create($payload);
if ($this->database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($this->database->getMorphClass() === \App\Models\ServiceDatabase::class) {
$this->dispatch('refreshScheduledBackups', $databaseBackup->id); $this->dispatch('refreshScheduledBackups', $databaseBackup->id);
} else { } else {
$this->dispatch('refreshScheduledBackups'); $this->dispatch('refreshScheduledBackups');

View File

@@ -77,10 +77,10 @@ class Import extends Component
} }
if ( if (
$this->resource->getMorphClass() == 'App\Models\StandaloneRedis' || $this->resource->getMorphClass() == \App\Models\StandaloneRedis::class ||
$this->resource->getMorphClass() == 'App\Models\StandaloneKeydb' || $this->resource->getMorphClass() == \App\Models\StandaloneKeydb::class ||
$this->resource->getMorphClass() == 'App\Models\StandaloneDragonfly' || $this->resource->getMorphClass() == \App\Models\StandaloneDragonfly::class ||
$this->resource->getMorphClass() == 'App\Models\StandaloneClickhouse' $this->resource->getMorphClass() == \App\Models\StandaloneClickhouse::class
) { ) {
$this->unsupported = true; $this->unsupported = true;
} }
@@ -108,19 +108,19 @@ class Import extends Component
$this->importCommands[] = "docker cp {$tmpPath} {$this->container}:{$tmpPath}"; $this->importCommands[] = "docker cp {$tmpPath} {$this->container}:{$tmpPath}";
switch ($this->resource->getMorphClass()) { switch ($this->resource->getMorphClass()) {
case 'App\Models\StandaloneMariadb': case \App\Models\StandaloneMariadb::class:
$this->importCommands[] = "docker exec {$this->container} sh -c '{$this->mariadbRestoreCommand} < {$tmpPath}'"; $this->importCommands[] = "docker exec {$this->container} sh -c '{$this->mariadbRestoreCommand} < {$tmpPath}'";
$this->importCommands[] = "rm {$tmpPath}"; $this->importCommands[] = "rm {$tmpPath}";
break; break;
case 'App\Models\StandaloneMysql': case \App\Models\StandaloneMysql::class:
$this->importCommands[] = "docker exec {$this->container} sh -c '{$this->mysqlRestoreCommand} < {$tmpPath}'"; $this->importCommands[] = "docker exec {$this->container} sh -c '{$this->mysqlRestoreCommand} < {$tmpPath}'";
$this->importCommands[] = "rm {$tmpPath}"; $this->importCommands[] = "rm {$tmpPath}";
break; break;
case 'App\Models\StandalonePostgresql': case \App\Models\StandalonePostgresql::class:
$this->importCommands[] = "docker exec {$this->container} sh -c '{$this->postgresqlRestoreCommand} {$tmpPath}'"; $this->importCommands[] = "docker exec {$this->container} sh -c '{$this->postgresqlRestoreCommand} {$tmpPath}'";
$this->importCommands[] = "rm {$tmpPath}"; $this->importCommands[] = "rm {$tmpPath}";
break; break;
case 'App\Models\StandaloneMongodb': case \App\Models\StandaloneMongodb::class:
$this->importCommands[] = "docker exec {$this->container} sh -c '{$this->mongodbRestoreCommand}{$tmpPath}'"; $this->importCommands[] = "docker exec {$this->container} sh -c '{$this->mongodbRestoreCommand}{$tmpPath}'";
$this->importCommands[] = "rm {$tmpPath}"; $this->importCommands[] = "rm {$tmpPath}";
break; break;

View File

@@ -29,7 +29,7 @@ class ScheduledBackups extends Component
$this->setSelectedBackup($this->selectedBackupId, true); $this->setSelectedBackup($this->selectedBackupId, true);
} }
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
if ($this->database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($this->database->getMorphClass() === \App\Models\ServiceDatabase::class) {
$this->type = 'service-database'; $this->type = 'service-database';
} else { } else {
$this->type = 'database'; $this->type = 'database';

View File

@@ -213,7 +213,7 @@ class PublicGitRepository extends Component
return; return;
} }
if ($this->git_source->getMorphClass() === 'App\Models\GithubApp') { if ($this->git_source->getMorphClass() === \App\Models\GithubApp::class) {
['rate_limit_remaining' => $this->rate_limit_remaining, 'rate_limit_reset' => $this->rate_limit_reset] = githubApi(source: $this->git_source, endpoint: "/repos/{$this->git_repository}/branches/{$this->git_branch}"); ['rate_limit_remaining' => $this->rate_limit_remaining, 'rate_limit_reset' => $this->rate_limit_reset] = githubApi(source: $this->git_source, endpoint: "/repos/{$this->git_repository}/branches/{$this->git_branch}");
$this->rate_limit_reset = Carbon::parse((int) $this->rate_limit_reset)->format('Y-M-d H:i:s'); $this->rate_limit_reset = Carbon::parse((int) $this->rate_limit_reset)->format('Y-M-d H:i:s');
$this->branchFound = true; $this->branchFound = true;

View File

@@ -35,7 +35,7 @@ class All extends Component
public function mount() public function mount()
{ {
$this->resourceClass = get_class($this->resource); $this->resourceClass = get_class($this->resource);
$resourceWithPreviews = ['App\Models\Application']; $resourceWithPreviews = [\App\Models\Application::class];
$simpleDockerfile = ! is_null(data_get($this->resource, 'dockerfile')); $simpleDockerfile = ! is_null(data_get($this->resource, 'dockerfile'));
if (str($this->resourceClass)->contains($resourceWithPreviews) && ! $simpleDockerfile) { if (str($this->resourceClass)->contains($resourceWithPreviews) && ! $simpleDockerfile) {
$this->showPreview = true; $this->showPreview = true;

View File

@@ -58,7 +58,7 @@ class Show extends Component
public function mount() public function mount()
{ {
if ($this->env->getMorphClass() === 'App\Models\SharedEnvironmentVariable') { if ($this->env->getMorphClass() === \App\Models\SharedEnvironmentVariable::class) {
$this->isSharedVariable = true; $this->isSharedVariable = true;
} }
$this->modalId = new Cuid2; $this->modalId = new Cuid2;
@@ -80,7 +80,7 @@ class Show extends Component
public function serialize() public function serialize()
{ {
data_forget($this->env, 'real_value'); data_forget($this->env, 'real_value');
if ($this->env->getMorphClass() === 'App\Models\SharedEnvironmentVariable') { if ($this->env->getMorphClass() === \App\Models\SharedEnvironmentVariable::class) {
data_forget($this->env, 'is_build_time'); data_forget($this->env, 'is_build_time');
} }
} }

View File

@@ -44,7 +44,7 @@ class GetLogs extends Component
public function mount() public function mount()
{ {
if (! is_null($this->resource)) { if (! is_null($this->resource)) {
if ($this->resource->getMorphClass() === 'App\Models\Application') { if ($this->resource->getMorphClass() === \App\Models\Application::class) {
$this->showTimeStamps = $this->resource->settings->is_include_timestamps; $this->showTimeStamps = $this->resource->settings->is_include_timestamps;
} else { } else {
if ($this->servicesubtype) { if ($this->servicesubtype) {
@@ -53,7 +53,7 @@ class GetLogs extends Component
$this->showTimeStamps = $this->resource->is_include_timestamps; $this->showTimeStamps = $this->resource->is_include_timestamps;
} }
} }
if ($this->resource?->getMorphClass() === 'App\Models\Application') { if ($this->resource?->getMorphClass() === \App\Models\Application::class) {
if (str($this->container)->contains('-pr-')) { if (str($this->container)->contains('-pr-')) {
$this->pull_request = 'Pull Request: '.str($this->container)->afterLast('-pr-')->beforeLast('_')->value(); $this->pull_request = 'Pull Request: '.str($this->container)->afterLast('-pr-')->beforeLast('_')->value();
} }
@@ -69,11 +69,11 @@ class GetLogs extends Component
public function instantSave() public function instantSave()
{ {
if (! is_null($this->resource)) { if (! is_null($this->resource)) {
if ($this->resource->getMorphClass() === 'App\Models\Application') { if ($this->resource->getMorphClass() === \App\Models\Application::class) {
$this->resource->settings->is_include_timestamps = $this->showTimeStamps; $this->resource->settings->is_include_timestamps = $this->showTimeStamps;
$this->resource->settings->save(); $this->resource->settings->save();
} }
if ($this->resource->getMorphClass() === 'App\Models\Service') { if ($this->resource->getMorphClass() === \App\Models\Service::class) {
$serviceName = str($this->container)->beforeLast('-')->value(); $serviceName = str($this->container)->beforeLast('-')->value();
$subType = $this->resource->applications()->where('name', $serviceName)->first(); $subType = $this->resource->applications()->where('name', $serviceName)->first();
if ($subType) { if ($subType) {
@@ -95,7 +95,7 @@ class GetLogs extends Component
if (! $this->server->isFunctional()) { if (! $this->server->isFunctional()) {
return; return;
} }
if (! $refresh && ($this->resource?->getMorphClass() === 'App\Models\Service' || str($this->container)->contains('-pr-'))) { if (! $refresh && ($this->resource?->getMorphClass() === \App\Models\Service::class || str($this->container)->contains('-pr-'))) {
return; return;
} }
if ($this->numberOfLines <= 0 || is_null($this->numberOfLines)) { if ($this->numberOfLines <= 0 || is_null($this->numberOfLines)) {

View File

@@ -41,7 +41,7 @@ class ResourceOperations extends Component
} }
$uuid = (string) new Cuid2; $uuid = (string) new Cuid2;
$server = $new_destination->server; $server = $new_destination->server;
if ($this->resource->getMorphClass() === 'App\Models\Application') { if ($this->resource->getMorphClass() === \App\Models\Application::class) {
$new_resource = $this->resource->replicate()->fill([ $new_resource = $this->resource->replicate()->fill([
'uuid' => $uuid, 'uuid' => $uuid,
'name' => $this->resource->name.'-clone-'.$uuid, 'name' => $this->resource->name.'-clone-'.$uuid,
@@ -78,14 +78,14 @@ class ResourceOperations extends Component
return redirect()->to($route); return redirect()->to($route);
} elseif ( } elseif (
$this->resource->getMorphClass() === 'App\Models\StandalonePostgresql' || $this->resource->getMorphClass() === \App\Models\StandalonePostgresql::class ||
$this->resource->getMorphClass() === 'App\Models\StandaloneMongodb' || $this->resource->getMorphClass() === \App\Models\StandaloneMongodb::class ||
$this->resource->getMorphClass() === 'App\Models\StandaloneMysql' || $this->resource->getMorphClass() === \App\Models\StandaloneMysql::class ||
$this->resource->getMorphClass() === 'App\Models\StandaloneMariadb' || $this->resource->getMorphClass() === \App\Models\StandaloneMariadb::class ||
$this->resource->getMorphClass() === 'App\Models\StandaloneRedis' || $this->resource->getMorphClass() === \App\Models\StandaloneRedis::class ||
$this->resource->getMorphClass() === 'App\Models\StandaloneKeydb' || $this->resource->getMorphClass() === \App\Models\StandaloneKeydb::class ||
$this->resource->getMorphClass() === 'App\Models\StandaloneDragonfly' || $this->resource->getMorphClass() === \App\Models\StandaloneDragonfly::class ||
$this->resource->getMorphClass() === 'App\Models\StandaloneClickhouse' $this->resource->getMorphClass() === \App\Models\StandaloneClickhouse::class
) { ) {
$uuid = (string) new Cuid2; $uuid = (string) new Cuid2;
$new_resource = $this->resource->replicate()->fill([ $new_resource = $this->resource->replicate()->fill([

View File

@@ -83,7 +83,7 @@ class Add extends Component
]); ]);
$this->file_storage_path = trim($this->file_storage_path); $this->file_storage_path = trim($this->file_storage_path);
$this->file_storage_path = str($this->file_storage_path)->start('/')->value(); $this->file_storage_path = str($this->file_storage_path)->start('/')->value();
if ($this->resource->getMorphClass() === 'App\Models\Application') { if ($this->resource->getMorphClass() === \App\Models\Application::class) {
$fs_path = application_configuration_dir().'/'.$this->resource->uuid.$this->file_storage_path; $fs_path = application_configuration_dir().'/'.$this->resource->uuid.$this->file_storage_path;
} }
LocalFileVolume::create( LocalFileVolume::create(

View File

@@ -84,7 +84,7 @@ class SettingsBackup extends Component
'postgres_password' => $postgres_password, 'postgres_password' => $postgres_password,
'postgres_db' => $postgres_db, 'postgres_db' => $postgres_db,
'status' => 'running', 'status' => 'running',
'destination_type' => 'App\Models\StandaloneDocker', 'destination_type' => \App\Models\StandaloneDocker::class,
'destination_id' => 0, 'destination_id' => 0,
]); ]);
$this->backup = ScheduledDatabaseBackup::create([ $this->backup = ScheduledDatabaseBackup::create([
@@ -93,7 +93,7 @@ class SettingsBackup extends Component
'save_s3' => false, 'save_s3' => false,
'frequency' => '0 0 * * *', 'frequency' => '0 0 * * *',
'database_id' => $this->database->id, 'database_id' => $this->database->id,
'database_type' => 'App\Models\StandalonePostgresql', 'database_type' => \App\Models\StandalonePostgresql::class,
'team_id' => currentTeam()->id, 'team_id' => currentTeam()->id,
]); ]);
$this->database->refresh(); $this->database->refresh();

View File

@@ -936,7 +936,7 @@ class Application extends BaseModel
$source_html_url_host = $url['host']; $source_html_url_host = $url['host'];
$source_html_url_scheme = $url['scheme']; $source_html_url_scheme = $url['scheme'];
if ($this->source->getMorphClass() == 'App\Models\GithubApp') { if ($this->source->getMorphClass() == \App\Models\GithubApp::class) {
if ($this->source->is_public) { if ($this->source->is_public) {
$fullRepoUrl = "{$this->source->html_url}/{$customRepository}"; $fullRepoUrl = "{$this->source->html_url}/{$customRepository}";
$git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$customRepository} {$baseDir}"; $git_clone_command = "{$git_clone_command} {$this->source->html_url}/{$customRepository} {$baseDir}";

View File

@@ -65,7 +65,7 @@ class GithubApp extends BaseModel
{ {
return Attribute::make( return Attribute::make(
get: function () { get: function () {
if ($this->getMorphClass() === 'App\Models\GithubApp') { if ($this->getMorphClass() === \App\Models\GithubApp::class) {
return 'github'; return 'github';
} }
}, },

View File

@@ -52,7 +52,7 @@ class DeploymentSuccess extends Notification implements ShouldQueue
$channels = setNotificationChannels($notifiable, 'deployments'); $channels = setNotificationChannels($notifiable, 'deployments');
if (isCloud()) { if (isCloud()) {
// TODO: Make batch notifications work with email // TODO: Make batch notifications work with email
$channels = array_diff($channels, ['App\Notifications\Channels\EmailChannel']); $channels = array_diff($channels, [\App\Notifications\Channels\EmailChannel::class]);
} }
return $channels; return $channels;

View File

@@ -18,23 +18,23 @@ class TelegramChannel
$topicsInstance = get_class($notification); $topicsInstance = get_class($notification);
switch ($topicsInstance) { switch ($topicsInstance) {
case 'App\Notifications\Test': case \App\Notifications\Test::class:
$topicId = data_get($notifiable, 'telegram_notifications_test_message_thread_id'); $topicId = data_get($notifiable, 'telegram_notifications_test_message_thread_id');
break; break;
case 'App\Notifications\Application\StatusChanged': case \App\Notifications\Application\StatusChanged::class:
case 'App\Notifications\Container\ContainerRestarted': case \App\Notifications\Container\ContainerRestarted::class:
case 'App\Notifications\Container\ContainerStopped': case \App\Notifications\Container\ContainerStopped::class:
$topicId = data_get($notifiable, 'telegram_notifications_status_changes_message_thread_id'); $topicId = data_get($notifiable, 'telegram_notifications_status_changes_message_thread_id');
break; break;
case 'App\Notifications\Application\DeploymentSuccess': case \App\Notifications\Application\DeploymentSuccess::class:
case 'App\Notifications\Application\DeploymentFailed': case \App\Notifications\Application\DeploymentFailed::class:
$topicId = data_get($notifiable, 'telegram_notifications_deployments_message_thread_id'); $topicId = data_get($notifiable, 'telegram_notifications_deployments_message_thread_id');
break; break;
case 'App\Notifications\Database\BackupSuccess': case \App\Notifications\Database\BackupSuccess::class:
case 'App\Notifications\Database\BackupFailed': case \App\Notifications\Database\BackupFailed::class:
$topicId = data_get($notifiable, 'telegram_notifications_database_backups_message_thread_id'); $topicId = data_get($notifiable, 'telegram_notifications_database_backups_message_thread_id');
break; break;
case 'App\Notifications\ScheduledTask\TaskFailed': case \App\Notifications\ScheduledTask\TaskFailed::class:
$topicId = data_get($notifiable, 'telegram_notifications_scheduled_tasks_thread_id'); $topicId = data_get($notifiable, 'telegram_notifications_scheduled_tasks_thread_id');
break; break;
} }

View File

@@ -25,7 +25,7 @@ class Test extends Notification implements ShouldQueue
public function middleware(object $notifiable, string $channel) public function middleware(object $notifiable, string $channel)
{ {
return match ($channel) { return match ($channel) {
'App\Notifications\Channels\EmailChannel' => [new RateLimited('email')], \App\Notifications\Channels\EmailChannel::class => [new RateLimited('email')],
default => [], default => [],
}; };
} }

View File

@@ -207,12 +207,12 @@ function defaultLabels($id, $name, $pull_request_id = 0, string $type = 'applica
} }
function generateServiceSpecificFqdns(ServiceApplication|Application $resource) function generateServiceSpecificFqdns(ServiceApplication|Application $resource)
{ {
if ($resource->getMorphClass() === 'App\Models\ServiceApplication') { if ($resource->getMorphClass() === \App\Models\ServiceApplication::class) {
$uuid = data_get($resource, 'uuid'); $uuid = data_get($resource, 'uuid');
$server = data_get($resource, 'service.server'); $server = data_get($resource, 'service.server');
$environment_variables = data_get($resource, 'service.environment_variables'); $environment_variables = data_get($resource, 'service.environment_variables');
$type = $resource->serviceType(); $type = $resource->serviceType();
} elseif ($resource->getMorphClass() === 'App\Models\Application') { } elseif ($resource->getMorphClass() === \App\Models\Application::class) {
$uuid = data_get($resource, 'uuid'); $uuid = data_get($resource, 'uuid');
$server = data_get($resource, 'destination.server'); $server = data_get($resource, 'destination.server');
$environment_variables = data_get($resource, 'environment_variables'); $environment_variables = data_get($resource, 'environment_variables');

View File

@@ -57,7 +57,7 @@ function githubApi(GithubApp|GitlabApp|null $source, string $endpoint, string $m
if (is_null($source)) { if (is_null($source)) {
throw new \Exception('Not implemented yet.'); throw new \Exception('Not implemented yet.');
} }
if ($source->getMorphClass() == 'App\Models\GithubApp') { if ($source->getMorphClass() == \App\Models\GithubApp::class) {
if ($source->is_public) { if ($source->is_public) {
$response = Http::github($source->api_url)->$method($endpoint); $response = Http::github($source->api_url)->$method($endpoint);
} else { } else {

View File

@@ -24,7 +24,7 @@ function replaceVariables(string $variable): Stringable
function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Application $oneService, bool $isInit = false) function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Application $oneService, bool $isInit = false)
{ {
try { try {
if ($oneService->getMorphClass() === 'App\Models\Application') { if ($oneService->getMorphClass() === \App\Models\Application::class) {
$workdir = $oneService->workdir(); $workdir = $oneService->workdir();
$server = $oneService->destination->server; $server = $oneService->destination->server;
} else { } else {

View File

@@ -669,7 +669,7 @@ function generateGitManualWebhook($resource, $type)
if ($resource->source_id !== 0 && ! is_null($resource->source_id)) { if ($resource->source_id !== 0 && ! is_null($resource->source_id)) {
return null; return null;
} }
if ($resource->getMorphClass() === 'App\Models\Application') { if ($resource->getMorphClass() === \App\Models\Application::class) {
$baseUrl = base_url(); $baseUrl = base_url();
$api = Url::fromString($baseUrl)."/webhooks/source/$type/events/manual"; $api = Url::fromString($baseUrl)."/webhooks/source/$type/events/manual";
@@ -685,7 +685,7 @@ function removeAnsiColors($text)
function getTopLevelNetworks(Service|Application $resource) function getTopLevelNetworks(Service|Application $resource)
{ {
if ($resource->getMorphClass() === 'App\Models\Service') { if ($resource->getMorphClass() === \App\Models\Service::class) {
if ($resource->docker_compose_raw) { if ($resource->docker_compose_raw) {
try { try {
$yaml = Yaml::parse($resource->docker_compose_raw); $yaml = Yaml::parse($resource->docker_compose_raw);
@@ -740,7 +740,7 @@ function getTopLevelNetworks(Service|Application $resource)
return $topLevelNetworks->keys(); return $topLevelNetworks->keys();
} }
} elseif ($resource->getMorphClass() === 'App\Models\Application') { } elseif ($resource->getMorphClass() === \App\Models\Application::class) {
try { try {
$yaml = Yaml::parse($resource->docker_compose_raw); $yaml = Yaml::parse($resource->docker_compose_raw);
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -1147,7 +1147,7 @@ function checkIfDomainIsAlreadyUsed(Collection|array $domains, ?string $teamId =
function check_domain_usage(ServiceApplication|Application|null $resource = null, ?string $domain = null) function check_domain_usage(ServiceApplication|Application|null $resource = null, ?string $domain = null)
{ {
if ($resource) { if ($resource) {
if ($resource->getMorphClass() === 'App\Models\Application' && $resource->build_pack === 'dockercompose') { if ($resource->getMorphClass() === \App\Models\Application::class && $resource->build_pack === 'dockercompose') {
$domains = data_get(json_decode($resource->docker_compose_domains, true), '*.domain'); $domains = data_get(json_decode($resource->docker_compose_domains, true), '*.domain');
$domains = collect($domains); $domains = collect($domains);
} else { } else {
@@ -1411,7 +1411,7 @@ function parseServiceVolumes($serviceVolumes, $resource, $topLevelVolumes, $pull
if ($source->value() === '/tmp' || $source->value() === '/tmp/') { if ($source->value() === '/tmp' || $source->value() === '/tmp/') {
return $volume; return $volume;
} }
if (get_class($resource) === "App\Models\Application") { if (get_class($resource) === \App\Models\Application::class) {
$dir = base_configuration_dir().'/applications/'.$resource->uuid; $dir = base_configuration_dir().'/applications/'.$resource->uuid;
} else { } else {
$dir = base_configuration_dir().'/services/'.$resource->service->uuid; $dir = base_configuration_dir().'/services/'.$resource->service->uuid;
@@ -1451,7 +1451,7 @@ function parseServiceVolumes($serviceVolumes, $resource, $topLevelVolumes, $pull
} }
} }
$slugWithoutUuid = Str::slug($source, '-'); $slugWithoutUuid = Str::slug($source, '-');
if (get_class($resource) === "App\Models\Application") { if (get_class($resource) === \App\Models\Application::class) {
$name = "{$resource->uuid}_{$slugWithoutUuid}"; $name = "{$resource->uuid}_{$slugWithoutUuid}";
} else { } else {
$name = "{$resource->service->uuid}_{$slugWithoutUuid}"; $name = "{$resource->service->uuid}_{$slugWithoutUuid}";
@@ -1494,7 +1494,7 @@ function parseServiceVolumes($serviceVolumes, $resource, $topLevelVolumes, $pull
function parseDockerComposeFile(Service|Application $resource, bool $isNew = false, int $pull_request_id = 0, ?int $preview_id = null) function parseDockerComposeFile(Service|Application $resource, bool $isNew = false, int $pull_request_id = 0, ?int $preview_id = null)
{ {
if ($resource->getMorphClass() === 'App\Models\Service') { if ($resource->getMorphClass() === \App\Models\Service::class) {
if ($resource->docker_compose_raw) { if ($resource->docker_compose_raw) {
try { try {
$yaml = Yaml::parse($resource->docker_compose_raw); $yaml = Yaml::parse($resource->docker_compose_raw);
@@ -2208,7 +2208,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
} else { } else {
return collect([]); return collect([]);
} }
} elseif ($resource->getMorphClass() === 'App\Models\Application') { } elseif ($resource->getMorphClass() === \App\Models\Application::class) {
try { try {
$yaml = Yaml::parse($resource->docker_compose_raw); $yaml = Yaml::parse($resource->docker_compose_raw);
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -3094,7 +3094,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
} }
} }
if ($value && get_class($value) === 'Illuminate\Support\Stringable' && $value->startsWith('/')) { if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) {
$path = $value->value(); $path = $value->value();
if ($path !== '/') { if ($path !== '/') {
$fqdn = "$fqdn$path"; $fqdn = "$fqdn$path";

View File

@@ -264,7 +264,7 @@ Route::middleware(['auth'])->group(function () {
} }
} }
$filename = data_get($execution, 'filename'); $filename = data_get($execution, 'filename');
if ($execution->scheduledDatabaseBackup->database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($execution->scheduledDatabaseBackup->database->getMorphClass() === \App\Models\ServiceDatabase::class) {
$server = $execution->scheduledDatabaseBackup->database->service->destination->server; $server = $execution->scheduledDatabaseBackup->database->service->destination->server;
} else { } else {
$server = $execution->scheduledDatabaseBackup->database->destination->server; $server = $execution->scheduledDatabaseBackup->database->destination->server;