mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 20:33:40 +00:00
feat: add update page, refactor update checking process
Some checks failed
tests / ci (push) Has been cancelled
Some checks failed
tests / ci (push) Has been cancelled
This commit is contained in:
parent
eb767fa6d0
commit
297a17d00b
17 changed files with 1212 additions and 241 deletions
48
resources/views/livewire/update-badge.blade.php
Normal file
48
resources/views/livewire/update-badge.blade.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Livewire\Component;
|
||||
|
||||
new class extends Component
|
||||
{
|
||||
public bool $hasUpdate = false;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->checkForUpdate();
|
||||
}
|
||||
|
||||
public function checkForUpdate(): void
|
||||
{
|
||||
$currentVersion = config('app.version');
|
||||
if (! $currentVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response = Cache::get('latest_release');
|
||||
if (! $response) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle both single release object and array of releases
|
||||
if (is_array($response) && isset($response[0])) {
|
||||
// Array of releases - find the latest one
|
||||
$latestRelease = $response[0];
|
||||
$latestVersion = Arr::get($latestRelease, 'tag_name');
|
||||
} else {
|
||||
// Single release object
|
||||
$latestVersion = Arr::get($response, 'tag_name');
|
||||
}
|
||||
|
||||
if ($latestVersion && version_compare($latestVersion, $currentVersion, '>')) {
|
||||
$this->hasUpdate = true;
|
||||
}
|
||||
}
|
||||
} ?>
|
||||
|
||||
<span>
|
||||
@if($hasUpdate)
|
||||
<flux:badge color="yellow"><flux:icon name="sparkles" class="size-4"/></flux:badge>
|
||||
@endif
|
||||
</span>
|
||||
Loading…
Add table
Add a link
Reference in a new issue