Files
fewo-stommer/app/Filament/Resources/InboxMessages/Tables/InboxMessagesTable.php
T
LarsandClaude Opus 5.5 b9225f5fb8 Doppelbuchungen nur einmal melden und im Postfach der Verwaltung zeigen
Der Kalenderabgleich alle 5 Minuten hat jede fortbestehende Ueberschneidung
erneut gemailt. ReportChannelConflicts legt jede Ueberschneidung einmal im
neuen Postfach (InboxMessage, Fingerabdruck je Mandant) ab und mailt nur neue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 09:52:35 +01:00

83 lines
3.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Filament\Resources\InboxMessages\Tables;
use App\Enums\InboxMessageKind;
use App\Models\InboxMessage;
use Filament\Actions\Action;
use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Collection;
class InboxMessagesTable
{
public static function configure(Table $table): Table
{
return $table
->defaultSort('created_at', 'desc')
->description('Hinweise, um die Sie sich kümmern sollten. Jede Meldung kommt nur einmal – auch wenn sie bei jedem Kalenderabgleich wieder auffällt.')
->emptyStateHeading('Keine Meldungen')
->columns([
IconColumn::make('read_at')
->label('')
->state(fn (InboxMessage $record): bool => ! $record->isRead())
->boolean()
->trueIcon(Heroicon::Envelope)
->falseIcon(Heroicon::OutlinedEnvelopeOpen)
->trueColor('danger')
->falseColor('gray')
->tooltip(fn (InboxMessage $record): string => $record->isRead() ? 'Gelesen' : 'Ungelesen'),
TextColumn::make('created_at')->label('Eingang')->dateTime('d.m. H:i')->sortable(),
TextColumn::make('kind')->label('Art')->badge(),
TextColumn::make('subject')
->label('Meldung')
->weight(fn (InboxMessage $record): ?FontWeight => $record->isRead() ? null : FontWeight::Bold)
->description(fn (InboxMessage $record): string => $record->body)
->wrap(),
])
->filters([
TernaryFilter::make('read_at')
->label('Gelesen')
->nullable()
->trueLabel('Nur gelesene')
->falseLabel('Nur ungelesene'),
SelectFilter::make('kind')->label('Art')->options(InboxMessageKind::class),
])
->recordUrl(null)
->recordActions([
Action::make('open')
->label('Ansehen')
->icon(Heroicon::OutlinedArrowTopRightOnSquare)
->visible(fn (InboxMessage $record): bool => filled($record->action_url))
->action(function (InboxMessage $record) {
$record->update(['read_at' => $record->read_at ?? now()]);
return redirect($record->action_url);
}),
Action::make('toggleRead')
->label(fn (InboxMessage $record): string => $record->isRead() ? 'Als ungelesen markieren' : 'Als gelesen markieren')
->icon(fn (InboxMessage $record): Heroicon => $record->isRead() ? Heroicon::OutlinedEnvelope : Heroicon::OutlinedCheck)
->color('gray')
->action(fn (InboxMessage $record) => $record->update(['read_at' => $record->isRead() ? null : now()])),
])
->toolbarActions([
BulkActionGroup::make([
BulkAction::make('markRead')
->label('Als gelesen markieren')
->icon(Heroicon::OutlinedCheck)
->action(fn (Collection $records) => InboxMessage::query()->whereKey($records->modelKeys())->update(['read_at' => now()]))
->deselectRecordsAfterCompletion(),
DeleteBulkAction::make(),
]),
]);
}
}