File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Illuminate \Database \Migrations \Migration ;
4
+ use Illuminate \Database \Schema \Blueprint ;
5
+ use Illuminate \Support \Facades \Schema ;
6
+
7
+ return new class extends Migration {
8
+ /**
9
+ * Run the migrations.
10
+ */
11
+ public function up (): void
12
+ {
13
+ Schema::table ('logs ' , function (Blueprint $ table ) {
14
+ $ table ->string ('message_id ' )->nullable ()->index ()->after ('id ' );
15
+ });
16
+ }
17
+
18
+ /**
19
+ * Reverse the migrations.
20
+ */
21
+ public function down (): void
22
+ {
23
+ Schema::table ('logs ' , function (Blueprint $ table ) {
24
+ $ table ->dropColumn ('message_id ' );
25
+ });
26
+ }
27
+ };
Original file line number Diff line number Diff line change 6
6
use Illuminate \Bus \Queueable ;
7
7
use Illuminate \Contracts \Queue \ShouldQueue ;
8
8
use Illuminate \Foundation \Bus \Dispatchable ;
9
+ use Illuminate \Mail \SentMessage ;
9
10
use Illuminate \Queue \InteractsWithQueue ;
10
11
use Illuminate \Queue \SerializesModels ;
11
12
use Illuminate \Support \Facades \Mail ;
@@ -77,7 +78,14 @@ public function handle(): void
77
78
*/
78
79
protected function send (): void
79
80
{
80
- $ sendMail = fn (?GenericMailDto $ override = null ) => Mail::send (new GenericMail ($ override ?: $ this ->genericMailDto ));
81
+ $ sendMail = function (?GenericMailDto $ override = null ) {
82
+ $ sent = Mail::send (new GenericMail ($ override ?: $ this ->genericMailDto ));
83
+
84
+ if ($ sent instanceof SentMessage) {
85
+ $ this ->log ->message_id = $ sent ->getMessageId ();
86
+ $ this ->log ->save ();
87
+ }
88
+ };
81
89
82
90
if ($ this ->sendingMiddleware ) {
83
91
$ middleware = unserialize ($ this ->sendingMiddleware )->getClosure ();
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ class Log extends Model
66
66
'status ' ,
67
67
'trigger ' ,
68
68
'subject ' ,
69
+ 'message_id ' ,
69
70
'cc ' ,
70
71
'bcc ' ,
71
72
'sender ' ,
You can’t perform that action at this time.
0 commit comments