34 lines
964 B
PHP
34 lines
964 B
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Models\Station;
|
|
use App\Models\Terminal;
|
|
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
|
|
|
class TerminalStatsWidget extends BaseWidget
|
|
{
|
|
protected static ?int $sort = 2;
|
|
|
|
protected function getStats(): array
|
|
{
|
|
// 统计终端数据
|
|
$totalStations = Station::count();
|
|
$totalTerminals = Terminal::count();
|
|
$onlineTerminals = Terminal::where('is_online', true)->count();
|
|
|
|
return [
|
|
Stat::make('线站数量', $totalStations)
|
|
->description('线站')
|
|
->descriptionIcon('heroicon-m-building-office')
|
|
->color('info'),
|
|
|
|
Stat::make('终端总数', $totalTerminals)
|
|
->description("{$onlineTerminals} 个在线")
|
|
->descriptionIcon('heroicon-m-computer-desktop')
|
|
->color('primary'),
|
|
];
|
|
}
|
|
}
|