feat: notification on filament dashboard

This commit is contained in:
2026-05-22 12:15:23 +02:00
parent 1c472e46db
commit 071d147888
9 changed files with 121 additions and 85 deletions
+9 -2
View File
@@ -10,7 +10,7 @@ use App\Models\MealPosts;
use App\Models\ModerationCase;
use App\Models\Report;
use App\Models\User;
use App\Notifications\ModerationThresholdReached;
use Filament\Notifications\Notification as FilamentNotification;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
@@ -112,7 +112,14 @@ class ModerationReportService
User::query()
->whereIn('role', [UserRole::ADMIN->value, UserRole::MODERATOR->value])
->get()
->each(fn (User $moderator): mixed => $moderator->notify(new ModerationThresholdReached($freshCase)));
->whenNotEmpty(fn ($moderators) => FilamentNotification::make()
->title(__('api.notifications.moderation_threshold_title'))
->body(__('api.notifications.moderation_threshold_body', [
'type' => $freshCase->targetLabel(),
'count' => $freshCase->reports_count,
]))
->warning()
->sendToDatabase($moderators, isEventDispatched: true));
}
private function abortIfInvalidTarget(Model $reportable, User $reporter): void