This commit is contained in:
2025-04-07 12:16:11 +01:00
parent ce8b201a1c
commit e15a80163b
62 changed files with 149 additions and 131 deletions

View File

@@ -36,21 +36,21 @@ class FirewallRule extends Model
public function command(bool $delete = false): string
{
$command = "ufw";
$command = 'ufw';
if ($delete) {
$command .= " delete";
$command .= ' delete';
}
if ($this->type === 'allow') {
$command .= " allow";
$command .= ' allow';
} elseif ($this->type === 'deny') {
$command .= " deny";
$command .= ' deny';
}
if ($this->from) {
$command .= " from {$this->from}";
$command .= " to any port";
$command .= ' to any port';
}
$command .= " {$this->ports}";

View File

@@ -29,7 +29,7 @@ class Network extends Model
{
return $this->hasMany(Server::class, 'external_network_id');
}
public function organisation(): BelongsTo
{
return $this->belongsTo(Organisation::class);

View File

@@ -45,8 +45,9 @@ class Organisation extends Model
$slug = Str::slug($name);
$count = 2;
while (Organisation::where('slug', $slug)->exists()) {
$slug = Str::slug($name) . '-' . $count++;
$slug = Str::slug($name).'-'.$count++;
}
return $slug;
}
}

View File

@@ -33,11 +33,11 @@ class Server extends Model
$existingServer = Server::whereOrganisationId($server->organisation_id)
->orderByDesc('internal_ip_ending')
->first();
$server->internal_ip_ending = $existingServer
? $existingServer->internal_ip_ending + 1
: 2;
$server->internal_ip = config('keystone.internal_ip_base') . $server->internal_ip_ending;
$server->internal_ip = config('keystone.internal_ip_base').$server->internal_ip_ending;
});
}
@@ -45,7 +45,7 @@ class Server extends Model
{
return $this->belongsTo(Network::class, 'external_network_id');
}
public function internalNetwork(): BelongsTo
{
return $this->belongsTo(Network::class, 'internal_network_id');

View File

@@ -41,12 +41,12 @@ class Service extends Model
public function driver(
?string $defaultPassword = null,
): Driver
{
): Driver {
$class = config("keystone.drivers.{$this->driver_name}");
if (!class_exists($class)) {
if (! class_exists($class)) {
throw new \Exception("Driver class {$class} not found");
}
return new $class($this->container_name, $this->container_id, defaultPassword: $defaultPassword);
}
}