Skip to content

Commit f6da0a4

Browse files
committed
Update README
1 parent 4096a4d commit f6da0a4

File tree

2 files changed

+57
-24
lines changed

2 files changed

+57
-24
lines changed

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Filament Mails can collect everything you might want to track about the mails th
1919

2020
Email as a protocol is very error prone. Succesfull email delivery is not guaranteed in any way, so it is best to monitor your email sending realtime. Using external services like Postmark, Mailgun or Resend email gets better by offering things like logging and delivery feedback, but it still needs your attention and can fail silently but horendously. Therefore we created Laravel Mails that fills in all the gaps.
2121

22+
The package is built on top of [Laravel Mails](https://github.com/vormkracht10/laravel-mails).
23+
24+
![Filament Mails](./docs/list.png)
25+
2226
## Installation
2327

2428
You can install the package via composer:
@@ -46,19 +50,35 @@ Optionally, you can publish the views using
4650
php artisan vendor:publish --tag="filament-mails-views"
4751
```
4852

49-
This is the contents of the published config file:
53+
Then add the plugin to your `PanelProvider`
5054

5155
```php
52-
return [
53-
];
56+
use Vormkracht10\FilamentMails\FilamentMails;
57+
58+
public function panel(Panel $panel): Panel
59+
{
60+
return $panel
61+
->plugin(FilamentMailsPlugin::make());
62+
}
5463
```
5564

65+
### Features and screenshots
66+
67+
#### List with all sent emails and statistics
68+
69+
![Filament Mails](./docs/list.png)
70+
71+
#### Preview email
72+
73+
![Filament Mails](./docs/view.png)
74+
75+
#### View relevant information
76+
77+
![Filament Mails](./docs/slideover.png)
78+
5679
## Usage
5780

58-
```php
59-
$filamentMails = new Vormkracht10\FilamentMails();
60-
echo $filamentMails->echoPhrase('Hello, Vormkracht10!');
61-
```
81+
..
6282

6383
## Testing
6484

src/Resources/MailResource.php

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
namespace Vormkracht10\FilamentMails\Resources;
44

5+
use Filament\Tables;
6+
use Filament\Tables\Table;
7+
use Filament\Infolists\Infolist;
8+
use Filament\Resources\Resource;
59
use Filament\Infolists\Components\Grid;
6-
use Filament\Infolists\Components\Section;
710
use Filament\Infolists\Components\Tabs;
11+
use Filament\Infolists\Components\Section;
812
use Filament\Infolists\Components\Tabs\Tab;
9-
use Filament\Infolists\Components\TextEntry;
10-
use Filament\Infolists\Infolist;
11-
use Filament\Resources\Resource;
12-
use Filament\Tables;
13-
use Filament\Tables\Table;
1413
use Vormkracht10\FilamentMails\Models\Mail;
14+
use Filament\Infolists\Components\TextEntry;
1515
use Vormkracht10\FilamentMails\Resources\MailResource\Pages\ListMails;
1616

1717
class MailResource extends Resource
@@ -68,22 +68,22 @@ public static function infolist(Infolist $infolist): Infolist
6868
->label(__('Subject')),
6969
TextEntry::make('from')
7070
->label(__('From'))
71-
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
71+
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
7272
TextEntry::make('to')
7373
->label(__('Recipient'))
74-
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
74+
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
7575
TextEntry::make('cc')
7676
->label(__('CC'))
7777
->default('-')
78-
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
78+
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
7979
TextEntry::make('bcc')
8080
->label(__('BCC'))
8181
->default('-')
82-
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
82+
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
8383
TextEntry::make('reply_to')
8484
->default('-')
8585
->label(__('Reply To'))
86-
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
86+
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
8787
]),
8888
]),
8989
Section::make('Content')
@@ -167,19 +167,17 @@ public static function infolist(Infolist $infolist): Infolist
167167
public static function table(Table $table): Table
168168
{
169169
return $table
170-
// ->recordAction('view')
171-
// ->recordUrl(null)
172170
->defaultSort('created_at', 'desc')
173171
->columns([
174172
Tables\Columns\TextColumn::make('status')
175173
->label(__('Status'))
176174
->sortable()
177175
->badge()
178-
->color(fn (string $state): string => match ($state) {
176+
->color(fn(string $state): string => match ($state) {
179177
'Hard Bounced' => 'danger',
180178
'Soft Bounced' => 'warning',
181179
'Complained' => 'danger',
182-
'Clicked' => 'success',
180+
'Clicked' => 'clicked',
183181
'Opened' => 'success',
184182
'Delivered' => 'success',
185183
'Sent' => 'info',
@@ -194,7 +192,7 @@ public static function table(Table $table): Table
194192
->searchable(),
195193
Tables\Columns\TextColumn::make('to')
196194
->label(__('Recipient'))
197-
->formatStateUsing(fn ($state) => self::formatEmailAddress($state))
195+
->formatStateUsing(fn($state) => self::formatEmailAddressForTable($state))
198196
->sortable()
199197
->searchable(),
200198
Tables\Columns\TextColumn::make('sent_at')
@@ -204,7 +202,7 @@ public static function table(Table $table): Table
204202
->searchable(),
205203
])
206204
->filters([
207-
//
205+
//
208206
])
209207
->actions([
210208
Tables\Actions\ViewAction::make()
@@ -243,4 +241,19 @@ private static function formatEmailAddress($state): string
243241
return $name === null ? $email : "$name <$email>";
244242
}, array_keys($data), $data));
245243
}
244+
245+
private static function formatEmailAddressForTable($state): string
246+
{
247+
if (empty($state)) {
248+
return '-';
249+
}
250+
251+
$data = json_decode($state, true);
252+
253+
if (!is_array($data)) {
254+
return (string) $state;
255+
}
256+
257+
return implode(', ', array_keys($data));
258+
}
246259
}

0 commit comments

Comments
 (0)