Skip to content

Commit

Permalink
[Bug] Added latest result to debug time zone (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjustesen authored Nov 30, 2023
1 parent a329335 commit 29ed394
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/Livewire/Debug/Timezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Livewire\Debug;

use App\Models\Result;
use App\Settings\GeneralSettings;
use Livewire\Attributes\Layout;
use Livewire\Component;
Expand All @@ -11,11 +12,17 @@ class Timezone extends Component
{
public $settings;

public ?Result $latest;

public function mount()
{
$settings = new GeneralSettings();

$this->settings = $settings->toArray();

$this->latest = Result::query()
->latest()
->first();
}

public function render()
Expand Down
20 changes: 20 additions & 0 deletions resources/views/livewire/debug/timezone.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,25 @@
</li>
</ul>
</div>

@isset($latest)
<div class="overflow-hidden bg-white shadow sm:rounded-md">
<div class="p-4 bg-white border-b border-gray-200 sm:px-6">
<h3 class="text-base font-semibold leading-6 text-gray-900">Latest result</h3>
</div>

<ul role="list" class="divide-y divide-gray-200">
<li class="px-4 py-4 sm:px-6">
<p class="text-sm font-medium text-gray-900">Latest result ran at</p>
<p class="text-sm text-gray-500 truncate">{{ $latest->created_at->timezone($settings['timezone'] ?? 'UTC')->format('M. jS, Y h:i:s') }}</p>
</li>

<li class="px-4 py-4 sm:px-6">
<p class="text-sm font-medium text-gray-900">Diff for humans</p>
<p class="text-sm text-gray-500 truncate">{{ $latest->created_at->diffForHumans() }}</p>
</li>
</ul>
</div>
@endisset
</div>
</div>

0 comments on commit 29ed394

Please sign in to comment.