File tree Expand file tree Collapse file tree 2 files changed +70
-3
lines changed Expand file tree Collapse file tree 2 files changed +70
-3
lines changed Original file line number Diff line number Diff line change 55use App \Helpers \Helper ;
66use App \Helpers \Inspiring ;
77use App \Helpers \Policy ;
8- use App \Nova \Metrics \DiskSpace ;
8+ use App \Nova \Metrics \Issues ;
99use App \Nova \Metrics \ServerResource ;
1010use Illuminate \Support \Facades \Auth ;
1111use Illuminate \Support \Facades \Storage ;
@@ -51,8 +51,15 @@ public function cards()
5151 ->verified (text: $ quotes ['author ' ])
5252 ->avatar (url: Storage::disk ('images ' )->url ('quotes.svg ' ))
5353 ->width ('1/2 ' ),
54- ServerResource::make ()->canSee (fn () => Policy::make ()->allowedFor ('admin ' )->get ()),
55- ServerResource::make ('inode ' )->canSee (fn () => Policy::make ()->allowedFor ('admin ' )->get ()),
54+ ServerResource::make ()
55+ ->width ('1/2 ' )
56+ ->canSee (fn () => Policy::make ()->allowedFor ('admin ' )->get ()),
57+ ServerResource::make ('inode ' )
58+ ->width ('1/2 ' )
59+ ->canSee (fn () => Policy::make ()->allowedFor ('admin ' )->get ()),
60+ Issues::make ('' )
61+ ->width ('1/2 ' )
62+ ->canSee (fn () => Policy::make ()->allowedFor ('admin ' )->get ()),
5663 Welcome::make ()
5764 ->title ('Permulaan ' ) // optional
5865 ->description ('Selamat datang di Aplikasi Simpede. Berikut adalah fitur-fitur yang tersedia: ' ) // optional
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Nova \Metrics ;
4+
5+ use DateTimeInterface ;
6+ use Laravel \Nova \Http \Requests \NovaRequest ;
7+ use Laravel \Nova \Metrics \Value ;
8+ use Laravel \Nova \Metrics \ValueResult ;
9+ use Laravel \Nova \Nova ;
10+ use Symfony \Component \Process \Process ;
11+
12+ class Issues extends Value
13+ {
14+ private $ type ;
15+
16+ public function __construct ($ type = 'issues ' )
17+ {
18+ $ this ->type = $ type ;
19+ }
20+
21+ public function name ()
22+ {
23+ return $ this ->type === 'issues ' ? 'Issues ' : 'Outdated Packages ' ;
24+ }
25+ /**
26+ * Calculate the value of the metric.
27+ */
28+ public function calculate (NovaRequest $ request ): ValueResult
29+ {
30+ $ composer = config ('app.composer ' );
31+ $ home = config ('app.composer_home ' );
32+ $ devFlag = '--no-dev ' ;
33+ $ process = Process::fromShellCommandline ("$ composer outdated $ devFlag -f json " , base_path (), ['COMPOSER_HOME ' => $ home ]);
34+ $ process ->run ();
35+ $ value = $ process ->getOutput ();
36+ return $ this ->result ($ value );
37+
38+
39+ }
40+
41+ /**
42+ * Get the ranges available for the metric.
43+ *
44+ * @return array<int|string, string>
45+ */
46+ public function ranges (): array
47+ {
48+ return [];
49+ }
50+
51+ /**
52+ * Determine the amount of time the results of the metric should be cached.
53+ */
54+ public function cacheFor (): DateTimeInterface |null
55+ {
56+ // return now()->addMinutes(5);
57+
58+ return null ;
59+ }
60+ }
You can’t perform that action at this time.
0 commit comments