Skip to content

Commit

Permalink
Merge branch '3.x' of github.com:BinarCode/laravel-mailator into 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryk committed Sep 3, 2021
2 parents 5d3ebd6 + 1872b17 commit a129aff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Actions/SendMailAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Binarcode\LaravelMailator\Actions;

use Binarcode\LaravelMailator\Contracts\Afterable;
use Binarcode\LaravelMailator\Contracts\Beforeable;
use Binarcode\LaravelMailator\Events\ScheduleMailSentEvent;
use Binarcode\LaravelMailator\Models\MailatorSchedule;
use Binarcode\LaravelMailator\Support\ClassResolver;
Expand Down Expand Up @@ -32,10 +34,18 @@ protected function sendMail(MailatorSchedule $schedule)
$mailable = $schedule->getMailable();

if ($mailable instanceof Mailable) {
if ($mailable instanceof Beforeable) {
$mailable->before();
}

Mail::to($schedule->getRecipients())->send($mailable);

$schedule->markAsSent();

if ($mailable instanceof Afterable) {
$mailable->after();
}

event(new ScheduleMailSentEvent($schedule));
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/Contracts/Afterable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Binarcode\LaravelMailator\Contracts;

interface Afterable
{
public function after();
}
8 changes: 8 additions & 0 deletions src/Contracts/Beforeable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Binarcode\LaravelMailator\Contracts;

interface Beforeable
{
public function before();
}

0 comments on commit a129aff

Please sign in to comment.