File "UpdateController.php"
Full Path: /var/www/drive/foundation/src/Core/Install/UpdateController.php
File size: 1.08 KB
MIME-type: text/x-php
Charset: utf-8
<?php namespace Common\Core\Install;
use Common\Core\BaseController;
use Common\Core\Install\CheckSiteHealth;
use Common\Core\Install\UpdateActions;
use Common\Settings\DotEnvEditor;
use Exception;
class UpdateController extends BaseController
{
public function __construct()
{
if (
!config('common.site.disable_update_auth') &&
version_compare(
config('common.site.version'),
$this->getAppVersion(),
) === 0
) {
$this->middleware('isAdmin');
}
}
public function show()
{
$data = (new CheckSiteHealth())->execute();
return view('common::install/update')->with($data);
}
public function performUpdate()
{
(new UpdateActions())->execute();
return view('common::install/update-complete');
}
private function getAppVersion(): string
{
try {
return (new DotEnvEditor('env.example'))->load()['app_version'];
} catch (Exception $e) {
return config('common.site.version');
}
}
}