ctrlpanel/app/Console/Commands/GetGithubVersion.php

44 lines
1 KiB
PHP
Raw Permalink Normal View History

2023-01-13 17:57:35 +00:00
<?php
namespace App\Console\Commands;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
class GetGithubVersion extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'cp:versioncheck:get';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Get the latest Version from Github';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
try{
2023-05-02 18:21:01 +00:00
$latestVersion = Http::get('https://api.github.com/repos/ctrlpanel-gg/panel/tags')->json()[0]['name'];
2023-01-13 17:57:35 +00:00
Storage::disk('local')->put('latestVersion', $latestVersion);
} catch (Exception $e) {
Storage::disk('local')->put('latestVersion', "unknown");
Log::error($e);
}
return Command::SUCCESS;
}
}