mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-04 01:09:58 -05:00
(Feature) Codebase Version Checker
- powered by the almighty vue.js
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class VersionController extends Controller
|
||||
{
|
||||
private $version;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->version = config('unit3d.version');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the latest release of UNIT3D and compare them to the local version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function checkVersion()
|
||||
{
|
||||
$client = new Client();
|
||||
$response = json_decode($client->get('https://api.github.com/repos/HDInnovations/UNIT3D/releases')->getBody());
|
||||
$lastestVersion = $response[0]->tag_name;
|
||||
return response(['updated' => version_compare($this->version, $lastestVersion, '<') ? 'true' : 'false']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user