Show if there's a new version available on the admin dashboard #143
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use \Illuminate\Support\Facades\Facade;
|
||||
|
||||
class Utils extends Facade
|
||||
@@ -11,6 +12,33 @@ class Utils extends Facade
|
||||
return 'utils';
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a URI. If a file is given, it will save the downloaded
|
||||
* content into that file
|
||||
* @param $uri
|
||||
* @param null $file
|
||||
* @return string
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function downloadUrl($uri, $file=null)
|
||||
{
|
||||
$opts = [];
|
||||
if($file !== null) {
|
||||
$opts['sink'] = $file;
|
||||
}
|
||||
|
||||
$client = new Client();
|
||||
$response = $client->request('GET', $uri, $opts);
|
||||
|
||||
$body = $response->getBody()->getContents();
|
||||
if($response->getHeader('content-type') === 'application/json') {
|
||||
$body = \GuzzleHttp\json_decode($body);
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a 40 character API key that a user can use
|
||||
* @return string
|
||||
|
||||
Reference in New Issue
Block a user