- DB: users.username (unique), users.preferred_locale (default from app.locale) - Backend: validation, model fillable; share supportedLocales; SetLocaleFromUser - Frontend: profile page fields + types - Filament: SuperAdmin profile page with username/language feat(admin-nav): move Tasks to Bibliothek and add menu labels fix(tasks-table): show localized title/emotion/event type; add translated headers feat(l10n): add missing table headers for emotions and event types; normalize en/de files refactor: tidy translations for tasks/emotions/event types
56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
use Filament\Widgets\ChartWidget;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class UploadsPerDayChart extends ChartWidget
|
|
{
|
|
protected ?string $heading = null;
|
|
protected ?string $maxHeight = '220px';
|
|
protected ?string $pollingInterval = '60s';
|
|
|
|
protected function getData(): array
|
|
{
|
|
// Build last 14 days labels
|
|
$labels = [];
|
|
$start = Carbon::now()->startOfDay()->subDays(13);
|
|
for ($i = 0; $i < 14; $i++) {
|
|
$labels[] = $start->copy()->addDays($i)->format('Y-m-d');
|
|
}
|
|
|
|
// SQLite-friendly group by date
|
|
$rows = DB::table('photos')
|
|
->selectRaw("strftime('%Y-%m-%d', created_at) as d, count(*) as c")
|
|
->where('created_at', '>=', $start)
|
|
->groupBy('d')
|
|
->orderBy('d')
|
|
->get();
|
|
$map = collect($rows)->keyBy('d');
|
|
$data = array_map(fn ($d) => (int) ($map[$d]->c ?? 0), $labels);
|
|
|
|
return [
|
|
'labels' => $labels,
|
|
'datasets' => [
|
|
[
|
|
'label' => __('admin.common.uploads'),
|
|
'data' => $data,
|
|
'borderColor' => '#f59e0b',
|
|
'backgroundColor' => 'rgba(245, 158, 11, 0.2)',
|
|
'tension' => 0.3,
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
protected function getType(): string
|
|
{
|
|
return 'line';
|
|
}
|
|
|
|
public function getHeading(): string|\Illuminate\Contracts\Support\Htmlable|null
|
|
{
|
|
return __('admin.widgets.uploads_per_day.heading');
|
|
}
|
|
} |