File tree Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Binarcode \LaravelMailator \Actions ;
44
5+ use Binarcode \LaravelMailator \Contracts \Afterable ;
6+ use Binarcode \LaravelMailator \Contracts \Beforeable ;
57use Binarcode \LaravelMailator \Events \ScheduleMailSentEvent ;
68use Binarcode \LaravelMailator \Models \MailatorSchedule ;
79use Binarcode \LaravelMailator \Support \ClassResolver ;
@@ -32,10 +34,18 @@ protected function sendMail(MailatorSchedule $schedule)
3234 $ mailable = $ schedule ->getMailable ();
3335
3436 if ($ mailable instanceof Mailable) {
37+ if ($ mailable instanceof Beforeable) {
38+ $ mailable ->before ();
39+ }
40+
3541 Mail::to ($ schedule ->getRecipients ())->send ($ mailable );
3642
3743 $ schedule ->markAsSent ();
3844
45+ if ($ mailable instanceof Afterable) {
46+ $ mailable ->after ();
47+ }
48+
3949 event (new ScheduleMailSentEvent ($ schedule ));
4050 }
4151 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Binarcode \LaravelMailator \Contracts ;
4+
5+ interface Afterable
6+ {
7+ public function after ();
8+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Binarcode \LaravelMailator \Contracts ;
4+
5+ interface Beforeable
6+ {
7+ public function before ();
8+ }
Original file line number Diff line number Diff line change 2525use Illuminate \Database \Eloquent \Relations \HasMany ;
2626use Illuminate \Support \Arr ;
2727use Illuminate \Support \Collection ;
28+ use Illuminate \Support \Facades \DB ;
2829use Illuminate \Support \Facades \Validator ;
2930use Illuminate \Support \Str ;
3031use Opis \Closure \SerializableClosure ;
You can’t perform that action at this time.
0 commit comments