Files
Atomcms-edit/app/Filament/Widgets/ArticlesAggregateChart.php
T
root 53f88b840a Modernize dependencies: replace abandoned packages, update versions
- Replace flowframe/laravel-trend with direct Eloquent DB queries
- Replace srmklive/paypal (abandoned) with new PayPalService using PayPal REST API v2 via Guzzle
- Remove old config/paypal.php, migrate to config('habbo.paypal.*')
- Update blade templates to use habbo.paypal config
- Bump npm packages to latest: @inertiajs/react, axios, esbuild, eslint, sass, tailwindcss, etc.
- Run composer update and yarn upgrade
2026-06-20 15:01:48 +02:00

61 lines
1.5 KiB
PHP
Executable File

<?php
namespace App\Filament\Widgets;
use App\Models\Articles\WebsiteArticle;
use Filament\Widgets\ChartWidget;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Facades\DB;
class ArticlesAggregateChart extends ChartWidget
{
#[\Override]
protected static ?int $sort = 2;
#[\Override]
protected ?string $maxHeight = '300px';
#[\Override]
protected string $color = 'primary';
#[\Override]
public function getHeading(): string|Htmlable|null
{
return __('filament::resources.stats.articles_chart.title');
}
#[\Override]
public function getDescription(): string|Htmlable|null
{
return __('filament::resources.stats.articles_chart.description');
}
#[\Override]
protected function getData(): array
{
$data = WebsiteArticle::query()
->whereBetween('created_at', [now()->startOfMonth(), now()->endOfMonth()])
->selectRaw('DATE(created_at) as date, COUNT(*) as aggregate')
->groupBy(DB::raw('DATE(created_at)'))
->orderBy('date')
->get();
$label = __('filament::resources.stats.articles_chart.label');
return [
'datasets' => [
[
'label' => $label,
'data' => $data->pluck('aggregate'),
],
],
'labels' => $data->pluck('date'),
];
}
protected function getType(): string
{
return 'line';
}
}