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 6ca1e25 + ad564c5 commit 3b7a755
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Route;
use Vormkracht10\FilamentMails\Controllers\MailPreviewController;
use Vormkracht10\FilamentMails\Controllers\MailDownloadController;
use Vormkracht10\FilamentMails\Controllers\MailPreviewController;

Route::get('/mail-preview/{mail}', MailPreviewController::class)->name('mail.preview');
Route::get('/mail-download/{attachment}', MailDownloadController::class)->name('mail.download');
Route::get('/mail-download/{attachment}', MailDownloadController::class)->name('mail.download');
3 changes: 1 addition & 2 deletions src/Controllers/MailDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Vormkracht10\Mails\Models\Mail;
use Illuminate\Support\Facades\Storage;
use Vormkracht10\Mails\Models\MailAttachment;

Expand All @@ -18,4 +17,4 @@ public function __invoke(Request $request)

return response()->download($file);
}
}
}
34 changes: 17 additions & 17 deletions src/Resources/MailResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,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 @@ -148,7 +148,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 => 'info',
WebhookEventType::OPEN => 'success',
Expand Down Expand Up @@ -181,7 +181,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 @@ -227,9 +227,9 @@ 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 @@ -246,7 +246,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 @@ -265,26 +265,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 @@ -402,4 +402,4 @@ private static function formatEmailAddressForTable($state): string

return implode(', ', array_keys($data));
}
}
}

0 comments on commit 3b7a755

Please sign in to comment.