diff --git a/app/Livewire/Project/Database/BackupExecutions.php b/app/Livewire/Project/Database/BackupExecutions.php index de1bac36f..79c1fcffc 100644 --- a/app/Livewire/Project/Database/BackupExecutions.php +++ b/app/Livewire/Project/Database/BackupExecutions.php @@ -8,9 +8,8 @@ use Livewire\Component; class BackupExecutions extends Component { public ?ScheduledDatabaseBackup $backup = null; - + public $database; public $executions = []; - public $setDeletableBackup; public function getListeners() @@ -61,4 +60,50 @@ class BackupExecutions extends Component $this->executions = $this->backup->executions()->get()->sortBy('created_at'); } } + + public function mount(ScheduledDatabaseBackup $backup) + { + $this->backup = $backup; + $this->database = $backup->database; + $this->refreshBackupExecutions(); + } + + public function server() + { + if ($this->database) { + $server = null; + + if ($this->database instanceof \App\Models\ServiceDatabase) { + $server = $this->database->service->destination->server; + } elseif ($this->database->destination && $this->database->destination->server) { + $server = $this->database->destination->server; + } + if ($server) { + return $server; + } + } + return null; + } + + public function getServerTimezone() + { + $server = $this->server(); + if (!$server) { + return 'UTC'; + } + $serverTimezone = $server->settings->server_timezone; + return $serverTimezone; + } + + public function formatDateInServerTimezone($date) + { + $serverTimezone = $this->getServerTimezone(); + $dateObj = new \DateTime($date); + try { + $dateObj->setTimezone(new \DateTimeZone($serverTimezone)); + } catch (\Exception $e) { + $dateObj->setTimezone(new \DateTimeZone('UTC')); + } + return $dateObj->format('Y-m-d H:i:s T'); + } } diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.php index 644ac9fa4..483fecc34 100644 --- a/resources/views/livewire/project/database/backup-executions.blade.php +++ b/resources/views/livewire/project/database/backup-executions.blade.php @@ -19,7 +19,7 @@ @endif