refactor: miscellaneous staff controller refactors

This commit is contained in:
Roardom
2023-06-21 04:10:58 +00:00
parent 939b140f3f
commit 5890ebc749
10 changed files with 39 additions and 62 deletions

View File

@@ -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,
]);
}