forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVersionChecker.php
More file actions
59 lines (50 loc) · 1.53 KB
/
VersionChecker.php
File metadata and controls
59 lines (50 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace App\Console\Commands;
use App\Models\User;
use App\Services\SystemChecker;
use Filament\Notifications\Actions\Action;
use Filament\Notifications\Notification;
use Illuminate\Console\Command;
class VersionChecker extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:version';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Sends a notification to the admin users when Speedtest Tracker is outdated.';
/**
* Execute the console command.
*/
public function handle()
{
$system = new SystemChecker;
if (! $system->isOutOfDate()) {
return Command::SUCCESS;
}
$admins = User::select(['id', 'name', 'email', 'role'])
->where('role', 'admin')
->get();
foreach ($admins as $user) {
Notification::make()
->title('Update Available')
->body("There's a new version of Speedtest Tracker available: {$system->getRemoteVersion()}")
->info()
->actions([
Action::make('view releases')
->button()
->color('gray')
->url('https://github.com/alexjustesen/speedtest-tracker/releases')
->openUrlInNewTab(),
])
->sendToDatabase($user);
}
return Command::SUCCESS;
}
}