mirror of
https://github.com/tiennm99/coolify.git
synced 2026-07-04 11:06:33 +00:00
refactor(scheduled-task): simplify server() with nullsafe operators and add return type
Replace nested null checks with nullsafe operator chains, add ?Server return type, drop unreachable database branch, and cover all paths with feature tests.
This commit is contained in:
@@ -76,20 +76,14 @@ class ScheduledTask extends BaseModel
|
||||
return $this->hasMany(ScheduledTaskExecution::class)->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
public function server()
|
||||
public function server(): ?Server
|
||||
{
|
||||
if ($this->application) {
|
||||
if ($this->application->destination && $this->application->destination->server) {
|
||||
return $this->application->destination->server;
|
||||
}
|
||||
} elseif ($this->service) {
|
||||
if ($this->service->destination && $this->service->destination->server) {
|
||||
return $this->service->destination->server;
|
||||
}
|
||||
} elseif ($this->database) {
|
||||
if ($this->database->destination && $this->database->destination->server) {
|
||||
return $this->database->destination->server;
|
||||
}
|
||||
return $this->application->destination?->server;
|
||||
}
|
||||
|
||||
if ($this->service) {
|
||||
return $this->service->destination?->server;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user