Initialize repo and add session changes (2025-09-08)
This commit is contained in:
31
app/Filament/Widgets/PlatformStatsWidget.php
Normal file
31
app/Filament/Widgets/PlatformStatsWidget.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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"),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user