mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
feat: show update notification
Displays a notice on the root page when a new version is available.
This commit is contained in:
parent
8bd5bcd76e
commit
c25432bc34
1 changed files with 31 additions and 1 deletions
|
|
@ -34,7 +34,37 @@
|
||||||
@auth
|
@auth
|
||||||
@if(config('app.version'))
|
@if(config('app.version'))
|
||||||
<flux:text class="text-xs">Version: <a href="https://github.com/usetrmnl/byos_laravel/releases/"
|
<flux:text class="text-xs">Version: <a href="https://github.com/usetrmnl/byos_laravel/releases/"
|
||||||
target="_blank">{{ config('app.version') }}</a></flux:text>
|
target="_blank">{{ config('app.version') }}</a>
|
||||||
|
</flux:text>
|
||||||
|
|
||||||
|
@php
|
||||||
|
$response = Cache::remember('latest_release', 86400, function () {
|
||||||
|
try {
|
||||||
|
$response = Http::get('https://api.github.com/repos/usetrmnl/byos_laravel/releases/latest');
|
||||||
|
if ($response->successful()) {
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::debug('Failed to fetch latest release: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
$latestVersion = Arr::get($response, 'tag_name');
|
||||||
|
|
||||||
|
if ($latestVersion && version_compare($latestVersion, config('app.version'), '>')) {
|
||||||
|
$newVersion = $latestVersion;
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@if(isset($newVersion))
|
||||||
|
<flux:callout class="text-xs mt-6" icon="arrow-down-circle">
|
||||||
|
<flux:callout.heading>Update available</flux:callout.heading>
|
||||||
|
<flux:callout.text>
|
||||||
|
There is a newer version {{ $newVersion }} available. Update to the latest version for the best experience.
|
||||||
|
<flux:callout.link href="https://github.com/usetrmnl/byos_laravel/releases/" target="_blank">Release notes</flux:callout.link>
|
||||||
|
</flux:callout.text>
|
||||||
|
</flux:callout>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@endauth
|
@endauth
|
||||||
</x-layouts.auth.card>
|
</x-layouts.auth.card>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue