fix
This commit is contained in:
parent
b68aabb2c9
commit
c9c56c915c
@ -51,6 +51,10 @@ class Form extends Component
|
|||||||
}
|
}
|
||||||
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 @@ class Server extends BaseModel
|
|||||||
'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 @@ class Server extends BaseModel
|
|||||||
{
|
{
|
||||||
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…
x
Reference in New Issue
Block a user