1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Http/Controllers/SelfUpdateController.php

67 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers;
use Codedge\Updater\UpdaterManager;
2017-01-30 20:40:43 +01:00
use Redirect;
use Utils;
class SelfUpdateController extends BaseController
{
/**
2017-01-30 20:40:43 +01:00
* @var UpdaterManager
*/
protected $updater;
/**
* SelfUpdateController constructor.
*
* @param UpdaterManager $updater
*/
public function __construct(UpdaterManager $updater)
{
if (Utils::isNinjaProd()) {
exit;
}
$this->updater = $updater;
}
/**
2017-01-30 20:40:43 +01:00
* Show default update page.
*
* @return mixed
*/
public function index()
{
$versionInstalled = $this->updater->source()->getVersionInstalled('v');
$updateAvailable = $this->updater->source()->isNewVersionAvailable($versionInstalled);
return view(
'vendor.self-update.self-update',
[
'versionInstalled' => $versionInstalled,
'versionAvailable' => $this->updater->source()->getVersionAvailable(),
2017-01-30 20:40:43 +01:00
'updateAvailable' => $updateAvailable,
]
);
}
/**
2017-01-30 20:40:43 +01:00
* Run the actual update.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function update()
{
$this->updater->source()->update();
return Redirect::to('/');
}
public function download()
{
$this->updater->source()->fetch();
}
}