internal ip ending

This commit is contained in:
2025-04-07 11:12:16 +01:00
parent 319520c650
commit 629d19a682
4 changed files with 37 additions and 0 deletions

View File

@@ -25,6 +25,22 @@ class Server extends Model
];
}
public static function boot(): void
{
parent::boot();
static::creating(function (self $server) {
// $server->internal_ip_ending = random_int(2, 254);
$existingServer = Server::whereOrganisationId($server->organisation_id)
->orderByDesc('internal_ip_ending')
->first();
$server->internal_ip_ending = $existingServer
? $existingServer->internal_ip_ending + 1
: 2;
});
}
public function externalNetwork(): BelongsTo
{
return $this->belongsTo(Network::class, 'external_network_id');