fix
This commit is contained in:
parent
b68aabb2c9
commit
c9c56c915c
4 changed files with 22 additions and 2 deletions
|
|
@ -51,6 +51,10 @@ public function validateServer()
|
||||||
}
|
}
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
|
if (!$this->server->isEmpty()) {
|
||||||
|
$this->emit('error', 'Server has defined resources. Please delete them first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->server->delete();
|
$this->server->delete();
|
||||||
redirect()->route('dashboard');
|
redirect()->route('dashboard');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ protected static function booted()
|
||||||
'server_id' => $server->id,
|
'server_id' => $server->id,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
static::deleting(function ($server) {
|
||||||
|
$server->settings()->delete();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
|
|
@ -33,6 +36,19 @@ public function scopeWithExtraAttributes(): Builder
|
||||||
{
|
{
|
||||||
return $this->extra_attributes->modelScope();
|
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()
|
public function destinations()
|
||||||
{
|
{
|
||||||
$standalone_docker = $this->hasMany(StandaloneDocker::class)->get();
|
$standalone_docker = $this->hasMany(StandaloneDocker::class)->get();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<x-forms.button wire:click.prevent='submit' type="submit">
|
<x-forms.button wire:click.prevent='submit' type="submit">
|
||||||
Save
|
Save
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
@if ($destination->network !== 'coolify')
|
@if ($destination->server->id === 0 && $destination->network !== 'coolify')
|
||||||
<x-forms.button x-on:click.prevent="deleteDestination = true">
|
<x-forms.button x-on:click.prevent="deleteDestination = true">
|
||||||
Delete
|
Delete
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<h2>General</h2>
|
<h2>General</h2>
|
||||||
<x-forms.button type="submit">Save</x-forms.button>
|
<x-forms.button type="submit">Save</x-forms.button>
|
||||||
@if ($server->id !== 0)
|
@if ($server->id !== 0 || config('app.env') === 'local')
|
||||||
<x-forms.button x-on:click.prevent="deleteServer = true">
|
<x-forms.button x-on:click.prevent="deleteServer = true">
|
||||||
Delete
|
Delete
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue