fix DB server

This commit is contained in:
ayntk-ai
2024-08-16 19:29:44 +02:00
parent 4af7b8f451
commit 789adc77fd

View File

@@ -34,22 +34,20 @@ class ScheduledDatabaseBackup extends BaseModel
{
return $this->hasMany(ScheduledDatabaseBackupExecution::class)->where('created_at', '>=', now()->subDays($days))->get();
}
public function server()
{
$database = $this->database;
if (!$database) {
return null;
if ($this->database) {
if ($this->database->destination && $this->database->destination->server) {
$server = $this->database->destination->server;
ray('Server found:', $server);
ray('Server details:', [
'id' => $server->id,
'name' => $server->name,
'ip' => $server->ip
]);
return $server;
}
}
if (method_exists($database, 'server')) {
return $database->server;
}
if (method_exists($database, 'service') && $database->service) {
return $database->service->server;
}
return null;
}
}