File tree 6 files changed +46
-11
lines changed
6 files changed +46
-11
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,11 @@ return [
59
59
* The Carbon format which should be used to display the UTC timestamp.
60
60
*/
61
61
'format' => 'd M Hi\Z',
62
+
63
+ /*
64
+ * Whether the component should poll every second to keep the time synced.
65
+ */
66
+ 'should_poll' => true,
62
67
];
63
68
```
64
69
@@ -81,7 +86,7 @@ class AdminPanelProvider extends PanelProvider
81
86
{
82
87
return $panel
83
88
// ...
84
- ->plugin( FilamentUtcDtsPlugin::make());
89
+ ->plugins([ FilamentUtcDtsPlugin::make()] );
85
90
}
86
91
}
87
92
```
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- // config for Gerenuk/FilamentUtcDts
4
3
return [
5
4
/*
6
5
* The Carbon format which should be used to display the UTC timestamp.
7
6
*/
8
7
'format ' => 'd M Hi\Z ' ,
8
+
9
+ /*
10
+ * Whether the component should poll every second to keep the time synced.
11
+ */
12
+ 'should_poll ' => true ,
9
13
];
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <span @if (config (' filament-utc-dts.should_poll' , true ) ) wire:poll.1s =" updateTime" @endif
2
+ class =" sm:flex hidden items-center rounded-lg bg-white dark:bg-white/5 px-3 h-9 text-sm font-medium text-gray-400 dark:text-gray-500 ring-1 ring-gray-950/10 dark:ring-white/20 shadow-sm" >
3
+ {{ $datestamp } }
4
+ </span >
Original file line number Diff line number Diff line change 4
4
5
5
use Filament \Contracts \Plugin ;
6
6
use Filament \Panel ;
7
- use Illuminate \ Support \ Carbon ;
8
- use Illuminate \ Support \ Facades \ View ;
7
+ use Gerenuk \ FilamentUtcDts \ Livewire \ UtcBadge ;
8
+ use Livewire \ Livewire ;
9
9
10
10
class FilamentUtcDtsPlugin implements Plugin
11
11
{
@@ -16,12 +16,10 @@ public function getId(): string
16
16
17
17
public function register (Panel $ panel ): void
18
18
{
19
- $ panel ->renderHook ('panels::global-search.before ' , function () {
20
- $ timestamp = Carbon::now ()->utc ()->format (config ('filament-utc-dts.format ' ));
19
+ Livewire::component ('filament-utc-dts::utc-badge ' , UtcBadge::class);
21
20
22
- return View::make ('filament-utc-dts::badge ' , [
23
- 'datestamp ' => $ timestamp ,
24
- ]);
21
+ $ panel ->renderHook ('panels::global-search.before ' , function () {
22
+ return Livewire::mount ('filament-utc-dts::utc-badge ' );
25
23
});
26
24
}
27
25
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Gerenuk \FilamentUtcDts \Livewire ;
4
+
5
+ use Illuminate \Support \Carbon ;
6
+ use Livewire \Component ;
7
+
8
+ class UtcBadge extends Component
9
+ {
10
+ public string $ datestamp ;
11
+
12
+ public function mount (): void
13
+ {
14
+ $ this ->updateTime ();
15
+ }
16
+
17
+ public function updateTime (): void
18
+ {
19
+ $ this ->datestamp = Carbon::now ()->utc ()->format (config ('filament-utc-dts.format ' , 'd M Hi\Z ' ));
20
+ }
21
+
22
+ public function render ()
23
+ {
24
+ return view ('filament-utc-dts::utc-badge ' );
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments