mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-11 14:09:31 -06:00
refactor: miscellaneous staff controller refactors
This commit is contained in:
@@ -15,32 +15,21 @@ namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* @see \Tests\Todo\Feature\Http\Controllers\Staff\VersionControllerTest
|
||||
*/
|
||||
class VersionController extends Controller
|
||||
{
|
||||
private readonly mixed $versionController;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->versionController = config('unit3d.version');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the latest release of UNIT3D and compare them to the local version.
|
||||
*
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function checkVersion(): \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
{
|
||||
$latestVersion = Http::get('//api.github.com/repos/HDInnovations/UNIT3D/releases')[0]['tag_name'];
|
||||
|
||||
return response([
|
||||
'updated' => ! version_compare($this->versionController, $latestVersion, '<'),
|
||||
'updated' => ! version_compare(config('unit3d.version'), $latestVersion, '<'),
|
||||
'latestversion' => $latestVersion,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user