This commit is contained in:
Andras Bacsai
2023-06-15 15:15:27 +02:00
parent b68aabb2c9
commit c9c56c915c
4 changed files with 22 additions and 2 deletions

View File

@@ -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();