Files
fewo-stommer/app/Filament/Resources/Bookings/RelationManagers/InboundMessagesRelationManager.php
T
LarsandClaude Opus 5.5 3a039e5c50
Deploy FeWo mit PipelineManager / deploy (push) Successful in 5m10s
v0.11: Angebot wartet sichtbar auf Pflichtangaben; Postfach prüfen; Eingangsmails am Vorgang
- Vorgang: „Angebot prüfen und senden“ wird erst angeboten, wenn alle
  Pflichtangaben da sind („erst wenn alle Angaben da sind“); ebenso wartet
  „Buchungswunsch bestätigen?“. Die harte Sperre in SendOffer, AutoOffer
  und DecideBookingWish bestand bereits; jetzt stimmt auch die Anzeige.
- System › Betrieb: „Postfach prüfen“ (Verbindung, Anzahl Nachrichten der
  letzten Tage, nichts wird gelesen oder markiert) und Stand des Abrufs.
- Posteingang zeigt letzten erfolgreichen Abruf und letzten Fehler.
- Vorgang: neuer Bereich „Eingegangene E-Mails“ mit Lesen und Erkanntem;
  „Mailverlauf“ heißt jetzt „Gesendete E-Mails“.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 15:03:11 +01:00

61 lines
3.0 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\Bookings\RelationManagers;
use App\Models\InboundMessage;
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Support\HtmlString;
/**
* Communication log, incoming side (v0.11): every e-mail of the guest or the portal that the inbox assigned to this
* case, with what the evaluation found.
*/
class InboundMessagesRelationManager extends RelationManager
{
protected static string $relationship = 'inboundMessages';
protected static ?string $title = 'Eingegangene E-Mails';
public function isReadOnly(): bool
{
return true;
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('subject')
->defaultSort('received_at', 'desc')
->emptyStateHeading('Noch keine eingegangenen E-Mails zu diesem Vorgang')
->description('Antworten und Nachrichten aus dem Postfach für die Gästekommunikation, die diesem Vorgang zugeordnet sind. Nicht zugeordnete Nachrichten stehen unter Verwaltung › Posteingang.')
->columns([
TextColumn::make('received_at')->label('Eingang')->dateTime('d.m.Y, H:i'),
TextColumn::make('from_address')->label('Von')->description(fn (InboundMessage $record): ?string => $record->from_name),
TextColumn::make('subject')->label('Betreff')->wrap(),
TextColumn::make('extraction_status')->label('Auswertung')->badge()->formatStateUsing(fn (?string $state): string => match ($state) {
'done' => 'ausgewertet',
'failed' => 'nicht möglich',
'disabled' => 'ohne KI',
default => 'ausstehend',
}),
IconColumn::make('test_mode')->label('Testbetrieb')->boolean()->trueIcon(Heroicon::OutlinedBeaker)->falseIcon(null),
])
->recordActions([
Action::make('read')->label('Lesen')->icon(Heroicon::OutlinedEye)
->modalHeading(fn (InboundMessage $record): string => (string) $record->subject)
->modalSubmitAction(false)->modalCancelActionLabel('Schließen')->modalWidth('3xl')
->schema([
TextEntry::make('found')->label('Erkannt')->state(fn (InboundMessage $record): string => collect([...(array) ($record->extraction['applied'] ?? []), ...(array) ($record->extraction['proposed'] ?? [])])
->map(fn (array $fact): string => $fact['field'].': „'.$fact['value'].'“')->implode(' · ') ?: '–'),
TextEntry::make('body_text')->label('Nachricht')->state(fn (InboundMessage $record): HtmlString => new HtmlString(nl2br(e((string) $record->body)))),
]),
]);
}
}