* Add custom repository type for updates * Direct to self update module * Formatting
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace Modules\Updater\Http\Controllers;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use App\Repositories\KvpRepository;
|
||||
use App\Services\Installer\InstallerService;
|
||||
use App\Services\Installer\MigrationService;
|
||||
use App\Services\Installer\SeederService;
|
||||
use Codedge\Updater\UpdaterManager;
|
||||
use function count;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -13,22 +15,30 @@ use Illuminate\Support\Facades\Log;
|
||||
class UpdateController extends Controller
|
||||
{
|
||||
private $installerSvc;
|
||||
private $kvpRepo;
|
||||
private $migrationSvc;
|
||||
private $seederSvc;
|
||||
private $updateManager;
|
||||
|
||||
/**
|
||||
* @param InstallerService $installerSvc
|
||||
* @param MigrationService $migrationSvc
|
||||
* @param SeederService $seederSvc
|
||||
* @param KvpRepository $kvpRepo
|
||||
* @param UpdaterManager $updateManager
|
||||
*/
|
||||
public function __construct(
|
||||
InstallerService $installerSvc,
|
||||
KvpRepository $kvpRepo,
|
||||
MigrationService $migrationSvc,
|
||||
SeederService $seederSvc
|
||||
SeederService $seederSvc,
|
||||
UpdaterManager $updateManager
|
||||
) {
|
||||
$this->migrationSvc = $migrationSvc;
|
||||
$this->seederSvc = $seederSvc;
|
||||
$this->installerSvc = $installerSvc;
|
||||
$this->kvpRepo = $kvpRepo;
|
||||
$this->updateManager = $updateManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,4 +104,36 @@ class UpdateController extends Controller
|
||||
{
|
||||
return redirect('/login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the update page with the latest version
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function updater(Request $request)
|
||||
{
|
||||
$version = $this->kvpRepo->get('latest_version_tag');
|
||||
|
||||
return view('updater::downloader/downloader', [
|
||||
'version' => $version,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the actual update and then forward the user to the updater page
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_download(Request $request)
|
||||
{
|
||||
$version = $this->kvpRepo->get('latest_version_tag');
|
||||
$this->updateManager->source('github')->update($version);
|
||||
|
||||
Log::info('Update completed to '.$version.', redirecting');
|
||||
return redirect('/update');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user