@@ -84,22 +84,22 @@ public static function infolist(Infolist $infolist): Infolist
84
84
->label (__ ('Subject ' )),
85
85
TextEntry::make ('from ' )
86
86
->label (__ ('From ' ))
87
- ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->from )),
87
+ ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->from )),
88
88
TextEntry::make ('to ' )
89
89
->label (__ ('Recipient ' ))
90
- ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->to )),
90
+ ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->to )),
91
91
TextEntry::make ('cc ' )
92
92
->label (__ ('CC ' ))
93
93
->default ('- ' )
94
- ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->cc ?? [])),
94
+ ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->cc ?? [])),
95
95
TextEntry::make ('bcc ' )
96
96
->label (__ ('BCC ' ))
97
97
->default ('- ' )
98
- ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->bcc ?? [])),
98
+ ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->bcc ?? [])),
99
99
TextEntry::make ('reply_to ' )
100
100
->default ('- ' )
101
101
->label (__ ('Reply To ' ))
102
- ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->reply_to ?? [])),
102
+ ->getStateUsing (fn (Mail $ record ) => self ::formatMailState ($ record ->reply_to ?? [])),
103
103
]),
104
104
]),
105
105
Tab::make (__ ('Statistics ' ))
@@ -171,11 +171,11 @@ public static function infolist(Infolist $infolist): Infolist
171
171
TextEntry::make ('type ' )
172
172
->label (__ ('Type ' ))
173
173
->badge ()
174
- ->url (fn (MailEvent $ record ) => route ('filament. ' . filament ()->getCurrentPanel ()?->getId() . '.resources.mails.events.view ' , [
174
+ ->url (fn (MailEvent $ record ) => route ('filament. ' . filament ()->getCurrentPanel ()?->getId() . '.resources.mails.events.view ' , [
175
175
'record ' => $ record ,
176
176
'tenant ' => filament ()->getTenant ()?->id,
177
177
]))
178
- ->color (fn (EventType $ state ): string => match ($ state ) {
178
+ ->color (fn (EventType $ state ): string => match ($ state ) {
179
179
EventType::DELIVERED => 'success ' ,
180
180
EventType::CLICKED => 'clicked ' ,
181
181
EventType::OPENED => 'info ' ,
@@ -189,7 +189,7 @@ public static function infolist(Infolist $infolist): Infolist
189
189
return ucfirst ($ state ->value );
190
190
}),
191
191
TextEntry::make ('occurred_at ' )
192
- ->url (fn (MailEvent $ record ) => route ('filament. ' . filament ()->getCurrentPanel ()?->getId() . '.resources.mails.events.view ' , [
192
+ ->url (fn (MailEvent $ record ) => route ('filament. ' . filament ()->getCurrentPanel ()?->getId() . '.resources.mails.events.view ' , [
193
193
'record ' => $ record ,
194
194
'tenant ' => filament ()->getTenant ()?->id,
195
195
]))
@@ -219,7 +219,7 @@ public static function infolist(Infolist $infolist): Infolist
219
219
->hiddenLabel ()
220
220
->label (__ ('HTML Content ' ))
221
221
->extraAttributes (['class ' => 'overflow-x-auto ' ])
222
- ->formatStateUsing (fn (string $ state , Mail $ record ): View => view (
222
+ ->formatStateUsing (fn (string $ state , Mail $ record ): View => view (
223
223
'filament-mails::mails.preview ' ,
224
224
['html ' => $ state , 'mail ' => $ record ],
225
225
)),
@@ -229,7 +229,7 @@ public static function infolist(Infolist $infolist): Infolist
229
229
TextEntry::make ('html ' )
230
230
->hiddenLabel ()
231
231
->extraAttributes (['class ' => 'overflow-x-auto ' ])
232
- ->formatStateUsing (fn (string $ state , Mail $ record ): View => view (
232
+ ->formatStateUsing (fn (string $ state , Mail $ record ): View => view (
233
233
'filament-mails::mails.html ' ,
234
234
['html ' => $ state , 'mail ' => $ record ],
235
235
))
@@ -260,12 +260,12 @@ public static function infolist(Infolist $infolist): Infolist
260
260
TextEntry::make ('attachments ' )
261
261
->hiddenLabel ()
262
262
->label (__ ('Attachments ' ))
263
- ->visible (fn (Mail $ record ) => $ record ->attachments ->count () == 0 )
263
+ ->visible (fn (Mail $ record ) => $ record ->attachments ->count () == 0 )
264
264
->default (__ ('Email has no attachments ' )),
265
265
RepeatableEntry::make ('attachments ' )
266
266
->hiddenLabel ()
267
267
->label (__ ('Attachments ' ))
268
- ->visible (fn (Mail $ record ) => $ record ->attachments ->count () > 0 )
268
+ ->visible (fn (Mail $ record ) => $ record ->attachments ->count () > 0 )
269
269
->schema ([
270
270
Grid::make (3 )
271
271
->schema ([
@@ -277,7 +277,7 @@ public static function infolist(Infolist $infolist): Infolist
277
277
->label (__ ('Mime Type ' )),
278
278
ViewEntry::make ('uuid ' )
279
279
->label (__ ('Download ' ))
280
- ->getStateUsing (fn ($ record ) => $ record )
280
+ ->getStateUsing (fn ($ record ) => $ record )
281
281
->view ('filament-mails::mails.download ' ),
282
282
]),
283
283
]),
@@ -297,7 +297,7 @@ public static function table(Table $table): Table
297
297
->label (__ ('Status ' ))
298
298
->sortable ()
299
299
->badge ()
300
- ->color (fn (string $ state ): string => match ($ state ) {
300
+ ->color (fn (string $ state ): string => match ($ state ) {
301
301
__ ('Soft Bounced ' ) => 'warning ' ,
302
302
__ ('Hard Bounced ' ) => 'danger ' ,
303
303
__ ('Complained ' ) => 'danger ' ,
@@ -317,27 +317,27 @@ public static function table(Table $table): Table
317
317
Tables \Columns \IconColumn::make ('attachments ' )
318
318
->label ('' )
319
319
->alignLeft ()
320
- ->getStateUsing (fn (Mail $ record ) => $ record ->attachments ->count () > 0 )
321
- ->icon (fn (string $ state ): string => $ state ? 'heroicon-o-paper-clip ' : '' ),
320
+ ->getStateUsing (fn (Mail $ record ) => $ record ->attachments ->count () > 0 )
321
+ ->icon (fn (string $ state ): string => $ state ? 'heroicon-o-paper-clip ' : '' ),
322
322
Tables \Columns \TextColumn::make ('to ' )
323
323
->label (__ ('Recipient ' ))
324
324
->limit (50 )
325
- ->getStateUsing (fn (Mail $ record ) => self ::formatMailState (emails: $ record ->to , mailOnly: true ))
325
+ ->getStateUsing (fn (Mail $ record ) => self ::formatMailState (emails: $ record ->to , mailOnly: true ))
326
326
->sortable ()
327
327
->searchable (),
328
328
Tables \Columns \TextColumn::make ('opens ' )
329
329
->label (__ ('Opens ' ))
330
- ->tooltip (fn (Mail $ record ) => __ ('Last opened at :date ' , ['date ' => $ record ->last_opened_at ?->format('d-m-Y H:i ' )]))
330
+ ->tooltip (fn (Mail $ record ) => __ ('Last opened at :date ' , ['date ' => $ record ->last_opened_at ?->format('d-m-Y H:i ' )]))
331
331
->sortable (),
332
332
Tables \Columns \TextColumn::make ('clicks ' )
333
333
->label (__ ('Clicks ' ))
334
- ->tooltip (fn (Mail $ record ) => __ ('Last clicked at :date ' , ['date ' => $ record ->last_clicked_at ?->format('d-m-Y H:i ' )]))
334
+ ->tooltip (fn (Mail $ record ) => __ ('Last clicked at :date ' , ['date ' => $ record ->last_clicked_at ?->format('d-m-Y H:i ' )]))
335
335
->sortable (),
336
336
Tables \Columns \TextColumn::make ('sent_at ' )
337
337
->label (__ ('Sent At ' ))
338
338
->dateTime ('d-m-Y H:i ' )
339
339
->since ()
340
- ->tooltip (fn (Mail $ record ) => $ record ->sent_at ?->format('d-m-Y H:i ' ))
340
+ ->tooltip (fn (Mail $ record ) => $ record ->sent_at ?->format('d-m-Y H:i ' ))
341
341
->sortable ()
342
342
->searchable (),
343
343
])
@@ -402,16 +402,40 @@ public static function table(Table $table): Table
402
402
->modalDescription (__ ('Are you sure you want to resend the selected mails? ' ))
403
403
->hiddenLabel ()
404
404
->tooltip (__ ('Resend ' ))
405
+ ->form ([
406
+ TextInput::make ('to ' )
407
+ ->label (__ ('Recipient ' ))
408
+ ->helperText (__ ('You can add multiple email addresses separated by commas. ' ))
409
+ ->required (),
410
+ TextInput::make ('cc ' )
411
+ ->label (__ ('CC ' )),
412
+ TextInput::make ('bcc ' )
413
+ ->label (__ ('BCC ' )),
414
+ ])
415
+ ->fillForm (function () {
416
+ return [
417
+ 'to ' => '' ,
418
+ 'cc ' => '' ,
419
+ 'bcc ' => '' ,
420
+ ];
421
+ })
405
422
->action (function (Collection $ records , array $ data ) {
406
423
foreach ($ records as $ record ) {
407
- $ to = json_decode ($ record ->to , true ) ?? [];
408
- $ cc = json_decode ($ record ->cc , true ) ?? [];
409
- $ bcc = json_decode ($ record ->bcc , true ) ?? [];
410
- (new ResendMail )->handle ($ record , $ to , $ cc , $ bcc );
424
+ $ to = explode (', ' , $ data ['to ' ]);
425
+
426
+ if ($ data ['cc ' ]) {
427
+ $ data ['cc ' ] = explode (', ' , $ data ['cc ' ]);
428
+ }
429
+
430
+ if ($ data ['bcc ' ]) {
431
+ $ data ['bcc ' ] = explode (', ' , $ data ['bcc ' ]);
432
+ }
433
+
434
+ (new ResendMail )->handle ($ record , $ to , $ data ['cc ' ] ?? [], $ data ['bcc ' ] ?? []);
411
435
}
412
436
413
437
Notification::make ()
414
- ->title (__ ('Mails will be resent in the background ' ))
438
+ ->title (__ ('Mail will be resent in the background ' ))
415
439
->success ()
416
440
->send ();
417
441
}),
@@ -431,8 +455,8 @@ public static function getPages(): array
431
455
private static function formatMailState (array $ emails , bool $ mailOnly = false ): string
432
456
{
433
457
return collect ($ emails )
434
- ->mapWithKeys (fn ($ value , $ key ) => [$ key => $ value ?? $ key ])
435
- ->map (fn ($ value , $ key ) => $ mailOnly ? $ key : ($ value === null ? $ key : "$ value < $ key> " ))
458
+ ->mapWithKeys (fn ($ value , $ key ) => [$ key => $ value ?? $ key ])
459
+ ->map (fn ($ value , $ key ) => $ mailOnly ? $ key : ($ value === null ? $ key : "$ value < $ key> " ))
436
460
->implode (', ' );
437
461
}
438
462
@@ -442,4 +466,4 @@ public static function getWidgets(): array
442
466
MailStatsWidget::class,
443
467
];
444
468
}
445
- }
469
+ }
0 commit comments