2018-08-30 05:37:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use Illuminate\Contracts\Cache\Repository as Cache;
|
|
|
|
|
|
|
|
class ApplicationInformationService
|
|
|
|
{
|
2022-08-08 16:00:59 +00:00
|
|
|
public function __construct(private Client $client, private Cache $cache)
|
2018-08-30 05:37:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the latest version number of Koel from GitHub.
|
|
|
|
*/
|
2018-08-30 05:37:24 +00:00
|
|
|
public function getLatestVersionNumber(): string
|
|
|
|
{
|
2022-08-08 16:00:59 +00:00
|
|
|
return attempt(function () {
|
|
|
|
return $this->cache->remember('latestKoelVersion', now()->addDay(), function (): string {
|
2021-06-05 10:47:56 +00:00
|
|
|
return json_decode($this->client->get('https://api.github.com/repos/koel/koel/tags')->getBody())[0]
|
|
|
|
->name;
|
2022-08-08 16:00:59 +00:00
|
|
|
});
|
|
|
|
}) ?? koel_version();
|
2018-08-30 05:37:03 +00:00
|
|
|
}
|
|
|
|
}
|