koel/app/Services/ApplicationInformationService.php

27 lines
673 B
PHP
Raw Permalink Normal View History

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