mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
Introduce filament
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Widgets\LineChartWidget;
|
||||
use Flowframe\Trend\Trend;
|
||||
use Flowframe\Trend\TrendValue;
|
||||
|
||||
class UserTrend extends LineChartWidget
|
||||
{
|
||||
|
||||
protected static ?int $sort = 3;
|
||||
|
||||
protected function getHeading(): ?string
|
||||
{
|
||||
return __('dashboard.user_trend.page_title');
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$data = Trend::model(User::class)
|
||||
->dateColumn('added')
|
||||
->between(
|
||||
start: now()->subDays(30),
|
||||
end: now(),
|
||||
)
|
||||
->perDay()
|
||||
->count();
|
||||
|
||||
return [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'User',
|
||||
'data' => $data->map(fn (TrendValue $value) => $value->aggregate),
|
||||
],
|
||||
],
|
||||
'labels' => $data->map(fn (TrendValue $value) => Carbon::parse($value->date)->format('m-d')),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user