Files
mtdb_movie/common/Core/Install/UpdateController.php
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

44 lines
1.0 KiB
PHP
Executable File

<?php namespace Common\Core\Install;
use Common\Core\BaseController;
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');
}
}
}