File tree Expand file tree Collapse file tree 4 files changed +77
-0
lines changed Expand file tree Collapse file tree 4 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Illuminate \Support \Facades \Schema ;
4
+ use Illuminate \Database \Schema \Blueprint ;
5
+ use Illuminate \Database \Migrations \Migration ;
6
+
7
+ class AddQueuedAtToEmailsTable extends Migration
8
+ {
9
+ /**
10
+ * Run the migrations.
11
+ *
12
+ * @return void
13
+ */
14
+ public function up ()
15
+ {
16
+ if (Schema::hasColumn ('emails ' , 'queued_at ' )) {
17
+ return ;
18
+ }
19
+
20
+ Schema::table ('emails ' , function (Blueprint $ table ) {
21
+ $ table ->timestamp ('queued_at ' )->after ('encrypted ' )->nullable ();
22
+ });
23
+ }
24
+
25
+ /**
26
+ * Reverse the migrations.
27
+ *
28
+ * @return void
29
+ */
30
+ public function down ()
31
+ {
32
+ //
33
+ }
34
+ }
Original file line number Diff line number Diff line change 23
23
* @property $failed
24
24
* @property $error
25
25
* @property $encrypted
26
+ * @property $queued_at
26
27
* @property $scheduled_at
27
28
* @property $sent_at
28
29
* @property $delivered_at
@@ -277,6 +278,30 @@ public function getAttempts()
277
278
return $ this ->attempts ;
278
279
}
279
280
281
+ /**
282
+ * Get the queued date.
283
+ *
284
+ * @return mixed
285
+ */
286
+ public function getQueuedDate ()
287
+ {
288
+ return $ this ->queued_at ;
289
+ }
290
+
291
+ /**
292
+ * Get the queued date as a Carbon instance.
293
+ *
294
+ * @return Carbon
295
+ */
296
+ public function getQueuedDateAsCarbon ()
297
+ {
298
+ if ($ this ->queued_at instanceof Carbon) {
299
+ return $ this ->queued_at ;
300
+ }
301
+
302
+ return Carbon::parse ($ this ->queued_at );
303
+ }
304
+
280
305
/**
281
306
* Get the scheduled date.
282
307
*
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ public function prepare(EmailComposer $composer)
36
36
$ this ->prepareScheduled ($ composer );
37
37
38
38
$ this ->prepareImmediately ($ composer );
39
+
40
+ $ this ->prepareQueued ($ composer );
39
41
}
40
42
41
43
/**
@@ -235,4 +237,19 @@ private function prepareImmediately(EmailComposer $composer)
235
237
$ composer ->getEmail ()->fill (['sending ' => 1 ]);
236
238
}
237
239
}
240
+
241
+ /**
242
+ * Prepare the queued date.
243
+ *
244
+ * @param EmailComposer $composer
245
+ */
246
+ private function prepareQueued (EmailComposer $ composer )
247
+ {
248
+ if ($ this ->getData ('queued ' , false ) === true ) {
249
+ $ composer ->getEmail ()->fill ([
250
+ 'queued_at ' => Carbon::now ()->toDateTimeString (),
251
+ ]);
252
+ }
253
+ }
254
+
238
255
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public function getQueue()
19
19
return $ query
20
20
->whereNull ('deleted_at ' )
21
21
->whereNull ('sent_at ' )
22
+ ->whereNull ('queued_at ' )
22
23
->where (function ($ query ) {
23
24
$ query ->whereNull ('scheduled_at ' )
24
25
->orWhere ('scheduled_at ' , '<= ' , Carbon::now ()->toDateTimeString ());
You can’t perform that action at this time.
0 commit comments