Skip to content

Commit

Permalink
Add new event types and format value
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Sep 8, 2024
1 parent 9e5b429 commit d49e352
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Resources/EventResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('type')
->label(__('Type'))
->badge()
->color(fn (EventType $state): string => match ($state) {
->color(fn(EventType $state): string => match ($state) {
EventType::DELIVERED => 'success',
EventType::CLICKED => 'clicked',
EventType::OPENED => 'success',
EventType::SOFT_BOUNCED => 'danger',
EventType::HARD_BOUNCED => 'danger',
EventType::COMPLAINED => 'danger',
EventType::UNSUBSCRIBED => 'danger',
EventType::ACCEPTED => 'success',
})
->formatStateUsing(function (EventType $state) {
return ucfirst($state->value);
return ucwords(str_replace('_', ' ', $state->value));
}),
TextEntry::make('mail.subject')
->label(__('Mail')),
Expand Down Expand Up @@ -121,7 +123,7 @@ public static function infolist(Infolist $infolist): Infolist
->default(__('Unknown'))
->label(__('User Agent'))
->limit(50)
->tooltip(fn ($state) => $state),
->tooltip(fn($state) => $state),
]),
]),
Section::make(__('Location'))
Expand Down Expand Up @@ -150,7 +152,7 @@ public static function infolist(Infolist $infolist): Infolist
->default(__('Unknown'))
->label(__('Link'))
->limit(50)
->url(fn ($state) => $state)
->url(fn($state) => $state)
->openUrlInNewTab(),
TextEntry::make('tag')
->default(__('Unknown'))
Expand Down Expand Up @@ -198,20 +200,22 @@ public static function table(Table $table): Table
->label(__('Type'))
->sortable()
->badge()
->color(fn (EventType $state): string => match ($state) {
->color(fn(EventType $state): string => match ($state) {
EventType::DELIVERED => 'success',
EventType::CLICKED => 'clicked',
EventType::OPENED => 'success',
EventType::SOFT_BOUNCED => 'danger',
EventType::HARD_BOUNCED => 'danger',
EventType::COMPLAINED => 'danger',
EventType::UNSUBSCRIBED => 'danger',
EventType::ACCEPTED => 'success',
})
->formatStateUsing(function (EventType $state) {
return ucfirst($state->value);
return ucwords(str_replace('_', ' ', $state->value));
})
->searchable(),
Tables\Columns\TextColumn::make('mail.subject')
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.view', [
->url(fn(MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.view', [
'record' => $record->mail,
'tenant' => filament()->getTenant()?->id,

Check failure on line 220 in src/Resources/EventResource.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Illuminate\Database\Eloquent\Model::$id.
]))
Expand All @@ -221,7 +225,7 @@ public static function table(Table $table): Table
->label(__('Occurred At'))
->dateTime('d-m-Y H:i')
->since()
->tooltip(fn (MailEvent $record) => $record->occurred_at->format('d-m-Y H:i'))
->tooltip(fn(MailEvent $record) => $record->occurred_at->format('d-m-Y H:i'))
->sortable()
->searchable(),
])
Expand Down Expand Up @@ -249,4 +253,4 @@ public static function getPages(): array
'view' => ViewEvent::route('/{record}/view'),
];
}
}
}

0 comments on commit d49e352

Please sign in to comment.