2018-08-30 05:37:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use GuzzleHttp\Client;
|
2024-06-04 13:35:00 +00:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2018-08-30 05:37:03 +00:00
|
|
|
|
|
|
|
class ApplicationInformationService
|
|
|
|
{
|
2024-06-04 13:35:00 +00:00
|
|
|
public function __construct(private readonly Client $client)
|
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 () {
|
2024-06-04 13:35:00 +00:00
|
|
|
return 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
|
|
|
}
|
|
|
|
}
|