From 019ed43448af06499366f11a39b2400fd1b322a8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Wed, 30 Apr 2025 18:30:43 +0200 Subject: [PATCH] refactor(actions): standardize method naming for network and configuration deletion across application and service classes --- app/Actions/Application/StopApplication.php | 2 +- app/Actions/Service/DeleteService.php | 4 +-- app/Actions/Service/StopService.php | 2 +- app/Events/ApplicationStatusChanged.php | 13 +++---- app/Events/BackupCreated.php | 13 +++---- app/Events/CloudflareTunnelConfigured.php | 13 +++---- app/Events/DatabaseProxyStopped.php | 14 ++++---- app/Events/DatabaseStatusChanged.php | 16 ++++----- app/Events/FileStorageChanged.php | 10 ++++-- app/Events/ProxyStatusChanged.php | 13 +++---- app/Events/ScheduledTaskDone.php | 13 +++---- app/Events/ServiceStatusChanged.php | 15 ++++---- app/Events/TestEvent.php | 10 ++++-- app/Jobs/DeleteResourceJob.php | 38 +++++++++------------ app/Models/Application.php | 8 +++-- app/Models/Service.php | 8 ++--- app/Models/StandaloneClickhouse.php | 6 ++-- app/Models/StandaloneDragonfly.php | 6 ++-- app/Models/StandaloneKeydb.php | 6 ++-- app/Models/StandaloneMariadb.php | 6 ++-- app/Models/StandaloneMongodb.php | 6 ++-- app/Models/StandaloneMysql.php | 6 ++-- app/Models/StandalonePostgresql.php | 6 ++-- app/Models/StandaloneRedis.php | 6 ++-- 24 files changed, 123 insertions(+), 117 deletions(-) diff --git a/app/Actions/Application/StopApplication.php b/app/Actions/Application/StopApplication.php index 642b4ba45..f5f16f3fe 100644 --- a/app/Actions/Application/StopApplication.php +++ b/app/Actions/Application/StopApplication.php @@ -30,7 +30,7 @@ class StopApplication $application->stopContainers($containersToStop, $server); if ($application->build_pack === 'dockercompose') { - $application->delete_connected_networks($application->uuid); + $application->deleteConnectedNetworks(); } if ($dockerCleanup) { diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php index 9b87454da..372ffe397 100644 --- a/app/Actions/Service/DeleteService.php +++ b/app/Actions/Service/DeleteService.php @@ -48,7 +48,7 @@ class DeleteService } if ($deleteConnectedNetworks) { - $service->delete_connected_networks($service->uuid); + $service->deleteConnectedNetworks(); } instant_remote_process(["docker rm -f $service->uuid"], $server, throwError: false); @@ -56,7 +56,7 @@ class DeleteService throw new \Exception($e->getMessage()); } finally { if ($deleteConfigurations) { - $service->delete_configurations(); + $service->deleteConfigurations(); } foreach ($service->applications()->get() as $application) { $application->forceDelete(); diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php index e16dd5616..4bc2ecf03 100644 --- a/app/Actions/Service/StopService.php +++ b/app/Actions/Service/StopService.php @@ -24,7 +24,7 @@ class StopService $service->stopContainers($containersToStop, $server); if ($isDeleteOperation) { - $service->delete_connected_networks($service->uuid); + $service->deleteConnectedNetworks(); if ($dockerCleanup) { CleanupDocker::dispatch($server, true); } diff --git a/app/Events/ApplicationStatusChanged.php b/app/Events/ApplicationStatusChanged.php index 4433248aa..a20abac0f 100644 --- a/app/Events/ApplicationStatusChanged.php +++ b/app/Events/ApplicationStatusChanged.php @@ -12,21 +12,22 @@ class ApplicationStatusChanged implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $teamId; + public ?int $teamId = null; public function __construct($teamId = null) { - if (is_null($teamId)) { - $teamId = auth()->user()->currentTeam()->id ?? null; - } - if (is_null($teamId)) { - throw new \Exception('Team id is null'); + if (is_null($teamId) && auth()->check() && auth()->user()->currentTeam()) { + $teamId = auth()->user()->currentTeam()->id; } $this->teamId = $teamId; } public function broadcastOn(): array { + if (is_null($this->teamId)) { + return []; + } + return [ new PrivateChannel("team.{$this->teamId}"), ]; diff --git a/app/Events/BackupCreated.php b/app/Events/BackupCreated.php index 45b2aacb7..bc1ecee0d 100644 --- a/app/Events/BackupCreated.php +++ b/app/Events/BackupCreated.php @@ -12,21 +12,22 @@ class BackupCreated implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $teamId; + public ?int $teamId = null; public function __construct($teamId = null) { - if (is_null($teamId)) { - $teamId = auth()->user()->currentTeam()->id ?? null; - } - if (is_null($teamId)) { - throw new \Exception('Team id is null'); + if (is_null($teamId) && auth()->check() && auth()->user()->currentTeam()) { + $teamId = auth()->user()->currentTeam()->id; } $this->teamId = $teamId; } public function broadcastOn(): array { + if (is_null($this->teamId)) { + return []; + } + return [ new PrivateChannel("team.{$this->teamId}"), ]; diff --git a/app/Events/CloudflareTunnelConfigured.php b/app/Events/CloudflareTunnelConfigured.php index 3d7076d0d..b40c7d070 100644 --- a/app/Events/CloudflareTunnelConfigured.php +++ b/app/Events/CloudflareTunnelConfigured.php @@ -12,21 +12,22 @@ class CloudflareTunnelConfigured implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $teamId; + public ?int $teamId = null; public function __construct($teamId = null) { - if (is_null($teamId)) { - $teamId = auth()->user()->currentTeam()->id ?? null; - } - if (is_null($teamId)) { - throw new \Exception('Team id is null'); + if (is_null($teamId) && auth()->check() && auth()->user()->currentTeam()) { + $teamId = auth()->user()->currentTeam()->id; } $this->teamId = $teamId; } public function broadcastOn(): array { + if (is_null($this->teamId)) { + return []; + } + return [ new PrivateChannel("team.{$this->teamId}"), ]; diff --git a/app/Events/DatabaseProxyStopped.php b/app/Events/DatabaseProxyStopped.php index 96b35a5ca..8099b080d 100644 --- a/app/Events/DatabaseProxyStopped.php +++ b/app/Events/DatabaseProxyStopped.php @@ -7,27 +7,27 @@ use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Facades\Auth; class DatabaseProxyStopped implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $teamId; + public ?int $teamId = null; public function __construct($teamId = null) { - if (is_null($teamId)) { - $teamId = Auth::user()?->currentTeam()?->id ?? null; - } - if (is_null($teamId)) { - throw new \Exception('Team id is null'); + if (is_null($teamId) && auth()->check() && auth()->user()->currentTeam()) { + $teamId = auth()->user()->currentTeam()->id; } $this->teamId = $teamId; } public function broadcastOn(): array { + if (is_null($this->teamId)) { + return []; + } + return [ new PrivateChannel("team.{$this->teamId}"), ]; diff --git a/app/Events/DatabaseStatusChanged.php b/app/Events/DatabaseStatusChanged.php index 913b21bc2..d019da68c 100644 --- a/app/Events/DatabaseStatusChanged.php +++ b/app/Events/DatabaseStatusChanged.php @@ -13,28 +13,24 @@ class DatabaseStatusChanged implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $userId = null; + public int|string|null $userId = null; public function __construct($userId = null) { if (is_null($userId)) { $userId = Auth::id() ?? null; } - if (is_null($userId)) { - return false; - } - $this->userId = $userId; } public function broadcastOn(): ?array { - if (! is_null($this->userId)) { - return [ - new PrivateChannel("user.{$this->userId}"), - ]; + if (is_null($this->userId)) { + return []; } - return null; + return [ + new PrivateChannel("user.{$this->userId}"), + ]; } } diff --git a/app/Events/FileStorageChanged.php b/app/Events/FileStorageChanged.php index 57004cf4c..756cb1352 100644 --- a/app/Events/FileStorageChanged.php +++ b/app/Events/FileStorageChanged.php @@ -12,18 +12,22 @@ class FileStorageChanged implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $teamId; + public ?int $teamId = null; public function __construct($teamId = null) { - if (is_null($teamId)) { - throw new \Exception('Team id is null'); + if (is_null($teamId) && auth()->check() && auth()->user()->currentTeam()) { + $teamId = auth()->user()->currentTeam()->id; } $this->teamId = $teamId; } public function broadcastOn(): array { + if (is_null($this->teamId)) { + return []; + } + return [ new PrivateChannel("team.{$this->teamId}"), ]; diff --git a/app/Events/ProxyStatusChanged.php b/app/Events/ProxyStatusChanged.php index 35eedef70..6099d25ef 100644 --- a/app/Events/ProxyStatusChanged.php +++ b/app/Events/ProxyStatusChanged.php @@ -12,21 +12,22 @@ class ProxyStatusChanged implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $teamId; + public ?int $teamId = null; public function __construct($teamId = null) { - if (is_null($teamId)) { - $teamId = auth()->user()->currentTeam()->id ?? null; - } - if (is_null($teamId)) { - throw new \Exception('Team id is null'); + if (is_null($teamId) && auth()->check() && auth()->user()->currentTeam()) { + $teamId = auth()->user()->currentTeam()->id; } $this->teamId = $teamId; } public function broadcastOn(): array { + if (is_null($this->teamId)) { + return []; + } + return [ new PrivateChannel("team.{$this->teamId}"), ]; diff --git a/app/Events/ScheduledTaskDone.php b/app/Events/ScheduledTaskDone.php index c8b5547f6..9884c278b 100644 --- a/app/Events/ScheduledTaskDone.php +++ b/app/Events/ScheduledTaskDone.php @@ -12,21 +12,22 @@ class ScheduledTaskDone implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $teamId; + public ?int $teamId = null; public function __construct($teamId = null) { - if (is_null($teamId)) { - $teamId = auth()->user()->currentTeam()->id ?? null; - } - if (is_null($teamId)) { - throw new \Exception('Team id is null'); + if (is_null($teamId) && auth()->check() && auth()->user()->currentTeam()) { + $teamId = auth()->user()->currentTeam()->id; } $this->teamId = $teamId; } public function broadcastOn(): array { + if (is_null($this->teamId)) { + return []; + } + return [ new PrivateChannel("team.{$this->teamId}"), ]; diff --git a/app/Events/ServiceStatusChanged.php b/app/Events/ServiceStatusChanged.php index 3950022e1..f5a30e874 100644 --- a/app/Events/ServiceStatusChanged.php +++ b/app/Events/ServiceStatusChanged.php @@ -13,27 +13,24 @@ class ServiceStatusChanged implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public ?string $userId = null; + public int|string|null $userId = null; public function __construct($userId = null) { if (is_null($userId)) { $userId = Auth::id() ?? null; } - if (is_null($userId)) { - return false; - } $this->userId = $userId; } public function broadcastOn(): ?array { - if (! is_null($this->userId)) { - return [ - new PrivateChannel("user.{$this->userId}"), - ]; + if (is_null($this->userId)) { + return []; } - return null; + return [ + new PrivateChannel("user.{$this->userId}"), + ]; } } diff --git a/app/Events/TestEvent.php b/app/Events/TestEvent.php index 2cc6683dc..c6669c937 100644 --- a/app/Events/TestEvent.php +++ b/app/Events/TestEvent.php @@ -12,15 +12,21 @@ class TestEvent implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; - public $teamId; + public ?int $teamId = null; public function __construct() { - $this->teamId = auth()->user()->currentTeam()->id; + if (auth()->check() && auth()->user()->currentTeam()) { + $this->teamId = auth()->user()->currentTeam()->id; + } } public function broadcastOn(): array { + if (is_null($this->teamId)) { + return []; + } + return [ new PrivateChannel("team.{$this->teamId}"), ]; diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php index 9fd46db77..5cbf7953a 100644 --- a/app/Jobs/DeleteResourceJob.php +++ b/app/Jobs/DeleteResourceJob.php @@ -42,10 +42,8 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue public function handle() { try { - $persistentStorages = collect(); switch ($this->resource->type()) { case 'application': - $persistentStorages = $this->resource?->persistentStorages()?->get(); StopApplication::run($this->resource, previewDeployments: true); break; case 'standalone-postgresql': @@ -56,7 +54,6 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue case 'standalone-keydb': case 'standalone-dragonfly': case 'standalone-clickhouse': - $persistentStorages = $this->resource?->persistentStorages()?->get(); StopDatabase::run($this->resource, true); break; case 'service': @@ -64,11 +61,6 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue DeleteService::run($this->resource, $this->deleteConfigurations, $this->deleteVolumes, $this->dockerCleanup, $this->deleteConnectedNetworks); break; } - - if ($this->deleteVolumes && $this->resource->type() !== 'service') { - $this->resource->delete_volumes($persistentStorages); - $this->resource->persistentStorages()->delete(); - } $isDatabase = $this->resource instanceof StandalonePostgresql || $this->resource instanceof StandaloneRedis || $this->resource instanceof StandaloneMongodb @@ -79,29 +71,33 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue || $this->resource instanceof StandaloneClickhouse; if ($this->deleteConfigurations) { - $this->resource->delete_configurations(); // rename to FileStorages - $this->resource->fileStorages()->delete(); + $this->resource->deleteConfigurations(); } - if ($isDatabase) { - $this->resource->sslCertificates()->delete(); - $this->resource->scheduledBackups()->delete(); - $this->resource->environment_variables()->delete(); + if ($this->resource->type() === 'service') { $this->resource->tags()->detach(); + } else { + if ($this->deleteVolumes) { + $this->resource->deleteVolumes(); + $this->resource->persistentStorages()->delete(); + } + $this->resource->fileStorages()->delete(); + if ($isDatabase) { + $this->resource->sslCertificates()->delete(); + $this->resource->scheduledBackups()->delete(); + $this->resource->tags()->detach(); + } } + $this->resource->environment_variables()->delete(); - $server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server'); - if (($this->dockerCleanup || $isDatabase) && $server) { - CleanupDocker::dispatch($server, true); - } - - if ($this->deleteConnectedNetworks && ! $isDatabase) { - $this->resource?->delete_connected_networks($this->resource->uuid); + if ($this->deleteConnectedNetworks && ($this->resource->type() === 'service' || $this->resource->type() === 'application')) { + $this->resource->deleteConnectedNetworks(); } } catch (\Throwable $e) { throw $e; } finally { $this->resource->forceDelete(); if ($this->dockerCleanup) { + $server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server'); CleanupDocker::dispatch($server, true); } Artisan::queue('cleanup:stucked-resources'); diff --git a/app/Models/Application.php b/app/Models/Application.php index 124a62eb7..94bd5c75b 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -278,7 +278,7 @@ class Application extends BaseModel } } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -287,8 +287,9 @@ class Application extends BaseModel } } - public function delete_volumes(?Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($this->build_pack === 'dockercompose') { $server = data_get($this, 'destination.server'); instant_remote_process(["cd {$this->dirOnServer()} && docker compose down -v"], $server, false); @@ -303,8 +304,9 @@ class Application extends BaseModel } } - public function delete_connected_networks($uuid) + public function deleteConnectedNetworks() { + $uuid = $this->uuid; $server = data_get($this, 'destination.server'); instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false); instant_remote_process(["docker network rm {$uuid}"], $server, false); diff --git a/app/Models/Service.php b/app/Models/Service.php index 5232e5897..13e3a89c0 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -166,7 +166,7 @@ class Service extends BaseModel } } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -175,11 +175,11 @@ class Service extends BaseModel } } - public function delete_connected_networks($uuid) + public function deleteConnectedNetworks() { $server = data_get($this, 'destination.server'); - instant_remote_process(["docker network disconnect {$uuid} coolify-proxy"], $server, false); - instant_remote_process(["docker network rm {$uuid}"], $server, false); + instant_remote_process(["docker network disconnect {$this->uuid} coolify-proxy"], $server, false); + instant_remote_process(["docker network rm {$this->uuid}"], $server, false); } public function getStatusAttribute() diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.php index bc1f9b4b3..fcd81cdc9 100644 --- a/app/Models/StandaloneClickhouse.php +++ b/app/Models/StandaloneClickhouse.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; @@ -94,7 +93,7 @@ class StandaloneClickhouse extends BaseModel return database_configuration_dir()."/{$this->uuid}"; } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -103,8 +102,9 @@ class StandaloneClickhouse extends BaseModel } } - public function delete_volumes(Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($persistentStorages->count() === 0) { return; } diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.php index a14c5e378..fdf69b834 100644 --- a/app/Models/StandaloneDragonfly.php +++ b/app/Models/StandaloneDragonfly.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; @@ -94,7 +93,7 @@ class StandaloneDragonfly extends BaseModel return database_configuration_dir()."/{$this->uuid}"; } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -103,8 +102,9 @@ class StandaloneDragonfly extends BaseModel } } - public function delete_volumes(Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($persistentStorages->count() === 0) { return; } diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.php index 2d3aea755..d52023920 100644 --- a/app/Models/StandaloneKeydb.php +++ b/app/Models/StandaloneKeydb.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; @@ -94,7 +93,7 @@ class StandaloneKeydb extends BaseModel return database_configuration_dir()."/{$this->uuid}"; } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -103,8 +102,9 @@ class StandaloneKeydb extends BaseModel } } - public function delete_volumes(Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($persistentStorages->count() === 0) { return; } diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php index 7549ace3e..3c3ea6d39 100644 --- a/app/Models/StandaloneMariadb.php +++ b/app/Models/StandaloneMariadb.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; @@ -94,7 +93,7 @@ class StandaloneMariadb extends BaseModel return database_configuration_dir()."/{$this->uuid}"; } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -103,8 +102,9 @@ class StandaloneMariadb extends BaseModel } } - public function delete_volumes(Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($persistentStorages->count() === 0) { return; } diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php index 3092216bd..88833eebe 100644 --- a/app/Models/StandaloneMongodb.php +++ b/app/Models/StandaloneMongodb.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; @@ -98,7 +97,7 @@ class StandaloneMongodb extends BaseModel return database_configuration_dir()."/{$this->uuid}"; } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -107,8 +106,9 @@ class StandaloneMongodb extends BaseModel } } - public function delete_volumes(Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($persistentStorages->count() === 0) { return; } diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php index dbb5b1ae6..dedc35f91 100644 --- a/app/Models/StandaloneMysql.php +++ b/app/Models/StandaloneMysql.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; @@ -95,7 +94,7 @@ class StandaloneMysql extends BaseModel return database_configuration_dir()."/{$this->uuid}"; } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -104,8 +103,9 @@ class StandaloneMysql extends BaseModel } } - public function delete_volumes(Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($persistentStorages->count() === 0) { return; } diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php index a74d567a0..689134a32 100644 --- a/app/Models/StandalonePostgresql.php +++ b/app/Models/StandalonePostgresql.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; @@ -59,7 +58,7 @@ class StandalonePostgresql extends BaseModel ); } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -68,8 +67,9 @@ class StandalonePostgresql extends BaseModel } } - public function delete_volumes(Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($persistentStorages->count() === 0) { return; } diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php index fccbb24a5..7f6f2ad72 100644 --- a/app/Models/StandaloneRedis.php +++ b/app/Models/StandaloneRedis.php @@ -3,7 +3,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; @@ -96,7 +95,7 @@ class StandaloneRedis extends BaseModel return database_configuration_dir()."/{$this->uuid}"; } - public function delete_configurations() + public function deleteConfigurations() { $server = data_get($this, 'destination.server'); $workdir = $this->workdir(); @@ -105,8 +104,9 @@ class StandaloneRedis extends BaseModel } } - public function delete_volumes(Collection $persistentStorages) + public function deleteVolumes() { + $persistentStorages = $this->persistentStorages()->get() ?? collect(); if ($persistentStorages->count() === 0) { return; }