lasthourcloud/app/Http/Livewire/Upgrade.php
Andras Bacsai a378b5108e refactor a lot of things
fix: postgres_passwords could be longer
feat: able to define postgresql databases from the ui
2023-08-09 15:57:53 +02:00

45 lines
1.3 KiB
PHP

<?php
namespace App\Http\Livewire;
use App\Actions\Server\UpdateCoolify;
use App\Models\InstanceSettings;
use Livewire\Component;
use Masmerise\Toaster\Toaster;
class Upgrade extends Component
{
public bool $showProgress = false;
public bool $isUpgradeAvailable = false;
public string $latestVersion = '';
public function checkUpdate()
{
$this->latestVersion = get_latest_version_of_coolify();
$currentVersion = config('version');
version_compare($currentVersion, $this->latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false;
if (is_dev()) {
$this->isUpgradeAvailable = true;
}
$settings = InstanceSettings::get();
if ($settings->next_channel) {
$this->isUpgradeAvailable = true;
$this->latestVersion = 'next';
}
}
public function upgrade()
{
try {
if ($this->showProgress) {
return;
}
$this->showProgress = true;
resolve(UpdateCoolify::class)(true);
Toaster::success("Upgrading to {$this->latestVersion} version...");
} catch (\Exception $e) {
return general_error_handler(err: $e, that: $this);
}
}
}