Files
fotospiel-app/app/Filament/Widgets/PlatformStatsWidget.php
2025-09-08 14:03:43 +02:00

32 lines
955 B
PHP

<?php
namespace App\Filament\Widgets;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Carbon;
class PlatformStatsWidget extends BaseWidget
{
protected ?string $pollingInterval = '30s';
protected function getStats(): array
{
$now = Carbon::now();
$dayAgo = $now->copy()->subDay();
$tenants = (int) DB::table('tenants')->count();
$events = (int) DB::table('events')->count();
$photos = (int) DB::table('photos')->count();
$photos24h = (int) DB::table('photos')->where('created_at', '>=', $dayAgo)->count();
return [
Stat::make('Tenants', number_format($tenants)),
Stat::make('Events', number_format($events)),
Stat::make('Photos', number_format($photos))
->description("+{$photos24h} in last 24h"),
];
}
}