From a0689ca5fc6b7d7c5f75527d35b5a8a7a777dc31 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Fri, 16 Aug 2024 22:05:38 +0200 Subject: [PATCH] fix cron issues for UI and applications --- .../Shared/ScheduledTask/Executions.php | 8 +++-- app/Models/ScheduledTask.php | 35 +++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/Livewire/Project/Shared/ScheduledTask/Executions.php b/app/Livewire/Project/Shared/ScheduledTask/Executions.php index 332b400b8..5bd6b4b9b 100644 --- a/app/Livewire/Project/Shared/ScheduledTask/Executions.php +++ b/app/Livewire/Project/Shared/ScheduledTask/Executions.php @@ -34,9 +34,13 @@ class Executions extends Component } if ($this->task->application) { - return $this->task->application->server; + if ($this->task->application->destination && $this->task->application->destination->server) { + return $this->task->application->destination->server; + } } elseif ($this->task->service) { - return $this->task->service->server; + if ($this->task->service->destination && $this->task->service->destination->server) { + return $this->task->service->destination->server; + } } return null; } diff --git a/app/Models/ScheduledTask.php b/app/Models/ScheduledTask.php index 81ca6dba5..4641c2a85 100644 --- a/app/Models/ScheduledTask.php +++ b/app/Models/ScheduledTask.php @@ -4,6 +4,8 @@ namespace App\Models; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; +use App\Models\Service; +use App\Models\Application; class ScheduledTask extends BaseModel { @@ -31,27 +33,22 @@ class ScheduledTask extends BaseModel public function server() { - ray('Entering server() method in ScheduledTask model'); - if ($this->application) { - ray('Returning server from application'); - $server = $this->application->server; - ray('Returning server from application: '.$server); - return $server; - } - elseif ($this->database) { - ray('Returning server from database'); - $server = $this->database->server; - ray('Returning server from database: '.$server); - return $server; + if ($this->application->destination && $this->application->destination->server) { + $server = $this->application->destination->server; + return $server; + } } elseif ($this->service) { - ray('Returning server from service'); - $server = $this->service->server; - ray('Returning server from service: '.$server); - return $server; + if ($this->service->destination && $this->service->destination->server) { + $server = $this->service->destination->server; + return $server; + } + } elseif ($this->database) { + if ($this->database->destination && $this->database->destination->server) { + $server = $this->database->destination->server; + return $server; + } } - - ray('No server found, returning null'); return null; } -} \ No newline at end of file +}