fix
This commit is contained in:
@@ -51,6 +51,10 @@ class Form extends Component
|
||||
}
|
||||
public function delete()
|
||||
{
|
||||
if (!$this->server->isEmpty()) {
|
||||
$this->emit('error', 'Server has defined resources. Please delete them first.');
|
||||
return;
|
||||
}
|
||||
$this->server->delete();
|
||||
redirect()->route('dashboard');
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ class Server extends BaseModel
|
||||
'server_id' => $server->id,
|
||||
]);
|
||||
});
|
||||
static::deleting(function ($server) {
|
||||
$server->settings()->delete();
|
||||
});
|
||||
}
|
||||
protected $fillable = [
|
||||
'name',
|
||||
@@ -33,6 +36,19 @@ class Server extends BaseModel
|
||||
{
|
||||
return $this->extra_attributes->modelScope();
|
||||
}
|
||||
public function isEmpty()
|
||||
{
|
||||
if ($this->applications()->count() === 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function applications()
|
||||
{
|
||||
return $this->destinations()->map(function ($standaloneDocker) {
|
||||
return $standaloneDocker->applications;
|
||||
})->flatten();
|
||||
}
|
||||
public function destinations()
|
||||
{
|
||||
$standalone_docker = $this->hasMany(StandaloneDocker::class)->get();
|
||||
|
||||
Reference in New Issue
Block a user