Skip to content

Commit

Permalink
Merge branch 'main' of github.com:vormkracht10/filament-mails
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Sep 6, 2024
2 parents 5ef1624 + 071579c commit 9d6a4ce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions src/Resources/EventResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('type')
->label(__('Type'))
->badge()
->color(fn(WebhookEventType $state): string => match ($state) {
->color(fn (WebhookEventType $state): string => match ($state) {
WebhookEventType::DELIVERY => 'success',
WebhookEventType::CLICK => 'clicked',
WebhookEventType::OPEN => 'success',
Expand Down Expand Up @@ -114,7 +114,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 All @@ -141,7 +141,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 @@ -184,7 +184,7 @@ public static function table(Table $table): Table
->label(__('Type'))
->sortable()
->badge()
->color(fn(WebhookEventType $state): string => match ($state) {
->color(fn (WebhookEventType $state): string => match ($state) {
WebhookEventType::DELIVERY => 'success',
WebhookEventType::CLICK => 'clicked',
WebhookEventType::OPEN => 'success',
Expand All @@ -197,14 +197,14 @@ public static function table(Table $table): Table
})
->searchable(),
Tables\Columns\TextColumn::make('mail.subject')
->url(fn(MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.view', $record->mail))
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.view', $record->mail))
->label(__('Subject'))
->searchable(),
Tables\Columns\TextColumn::make('occurred_at')
->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'))

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

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property Vormkracht10\Mails\Models\MailEvent::$occurred_at.
->sortable()
->searchable(),
])
Expand Down Expand Up @@ -232,4 +232,4 @@ public static function getPages(): array
'view' => ViewEvent::route('/{record}/view'),
];
}
}
}
36 changes: 18 additions & 18 deletions src/Resources/MailResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,22 @@ public static function infolist(Infolist $infolist): Infolist
->label(__('Subject')),
TextEntry::make('from')
->label(__('From'))
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
TextEntry::make('to')
->label(__('Recipient'))
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
TextEntry::make('cc')
->label(__('CC'))
->default('-')
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
TextEntry::make('bcc')
->label(__('BCC'))
->default('-')
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
TextEntry::make('reply_to')
->default('-')
->label(__('Reply To'))
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
]),
]),
Tab::make(__('Statistics'))
Expand Down Expand Up @@ -149,8 +149,8 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('type')
->label(__('Type'))
->badge()
->url(fn(MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.events.view', $record))
->color(fn(WebhookEventType $state): string => match ($state) {
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.events.view', $record))
->color(fn (WebhookEventType $state): string => match ($state) {
WebhookEventType::DELIVERY => 'success',
WebhookEventType::CLICK => 'clicked',
WebhookEventType::OPEN => 'success',
Expand All @@ -162,7 +162,7 @@ public static function infolist(Infolist $infolist): Infolist
return ucfirst($state->value);
}),
TextEntry::make('occurred_at')
->url(fn(MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.events.view', $record))
->url(fn (MailEvent $record) => route('filament.' . filament()->getCurrentPanel()?->getId() . '.resources.mails.events.view', $record))
->since()
->dateTimeTooltip('d-m-Y H:i')
->label(__('Occurred At')),
Expand All @@ -187,7 +187,7 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('html')
->hiddenLabel()
->label(__('HTML Content'))
->formatStateUsing(fn(string $state, Mail $record): View => view(
->formatStateUsing(fn (string $state, Mail $record): View => view(
'filament-mails::mails.preview',
['html' => $state, 'mail' => $record],
)),
Expand Down Expand Up @@ -233,7 +233,7 @@ public static function infolist(Infolist $infolist): Infolist
->label(__('Mime Type')),
ViewEntry::make('uuid')
->label(__('Download'))
->getStateUsing(fn($record) => $record)
->getStateUsing(fn ($record) => $record)
->view('filament-mails::mails.download'),
]),
]),
Expand All @@ -252,7 +252,7 @@ public static function table(Table $table): Table
->label(__('Status'))
->sortable()
->badge()
->color(fn(string $state): string => match ($state) {
->color(fn (string $state): string => match ($state) {
'Hard Bounced' => 'danger',
'Soft Bounced' => 'warning',
'Complained' => 'danger',
Expand All @@ -271,26 +271,26 @@ public static function table(Table $table): Table
Tables\Columns\IconColumn::make('attachments')
->label('')
->alignLeft()
->getStateUsing(fn(Mail $record) => $record->attachments->count() > 0)
->icon(fn(string $state): string => $state ? 'heroicon-o-paper-clip' : ''),
->getStateUsing(fn (Mail $record) => $record->attachments->count() > 0)
->icon(fn (string $state): string => $state ? 'heroicon-o-paper-clip' : ''),
Tables\Columns\TextColumn::make('to')
->label(__('Recipient'))
->formatStateUsing(fn($state) => self::formatEmailAddressForTable($state))
->formatStateUsing(fn ($state) => self::formatEmailAddressForTable($state))
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('opens')
->label(__('Opens'))
->tooltip(fn(Mail $record) => __('Last opened at :date', ['date' => $record->last_opened_at?->format('d-m-Y H:i')]))
->tooltip(fn (Mail $record) => __('Last opened at :date', ['date' => $record->last_opened_at?->format('d-m-Y H:i')]))
->sortable(),
Tables\Columns\TextColumn::make('clicks')
->label(__('Clicks'))
->tooltip(fn(Mail $record) => __('Last clicked at :date', ['date' => $record->last_clicked_at?->format('d-m-Y H:i')]))
->tooltip(fn (Mail $record) => __('Last clicked at :date', ['date' => $record->last_clicked_at?->format('d-m-Y H:i')]))
->sortable(),
Tables\Columns\TextColumn::make('sent_at')
->label(__('Sent At'))
->dateTime('d-m-Y H:i')
->since()
->tooltip(fn(Mail $record) => $record->sent_at?->format('d-m-Y H:i'))
->tooltip(fn (Mail $record) => $record->sent_at?->format('d-m-Y H:i'))
->sortable()
->searchable(),
])
Expand Down Expand Up @@ -408,4 +408,4 @@ private static function formatEmailAddressForTable($state): string

return implode(', ', array_keys($data));
}
}
}
2 changes: 1 addition & 1 deletion src/Widgets/MailStatsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MailStatsWidget extends BaseWidget

protected function getStats(): array
{
$bouncedMails = Mail::where(fn($query) => $query->softBounced()->orWhere(fn($query) => $query->hardBounced()))->count();
$bouncedMails = Mail::where(fn ($query) => $query->softBounced()->orWhere(fn ($query) => $query->hardBounced()))->count();
$openedMails = Mail::opened()->count();
$deliveredMails = Mail::delivered()->count();
$clickedMails = Mail::clicked()->count();
Expand Down

0 comments on commit 9d6a4ce

Please sign in to comment.