Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

refactor(actions): standardize method naming for network and configuration deletion across application and service classes

Andras Bacsai019ed43448af
diff --git a/app/Actions/Application/StopApplication.php b/app/Actions/Application/StopApplication.php
index 642b4ba456..f5f16f3fe9 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 9b87454dac..372ffe3970 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 e16dd56163..4bc2ecf03b 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 4433248aad..a20abac0f5 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 45b2aacb7a..bc1ecee0d3 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 3d7076d0da..b40c7d070d 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 96b35a5cac..8099b080dc 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 913b21bc22..d019da68c5 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 57004cf4c3..756cb1352d 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 35eedef70e..6099d25efc 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 c8b5547f61..9884c278b4 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 3950022e10..f5a30e874b 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 2cc6683dc2..c6669c937c 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 9fd46db77d..5cbf7953a3 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 124a62eb7a..94bd5c75ba 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 5232e5897c..13e3a89c0e 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 bc1f9b4b37..fcd81cdc90 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 a14c5e3788..fdf69b8341 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 2d3aea7554..d52023920a 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 7549ace3e4..3c3ea6d39f 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 3092216bd7..88833eebe2 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 dbb5b1ae60..dedc35f919 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 a74d567a0a..689134a32f 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 fccbb24a58..7f6f2ad727 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;
}