koel/app/Services/ApplicationInformationService.php

27 lines
673 B
PHP
Raw Normal View History

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