added email subscriptions
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\SentEmail;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -48,6 +49,18 @@ class SendEmail implements ShouldQueue
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
// Record sent email
|
||||
$sentEmail = SentEmail::create([
|
||||
'recipient' => $this->to,
|
||||
'mailable_class' => get_class($this->mailable)
|
||||
]);
|
||||
|
||||
// Add unsubscribe link if mailable supports it
|
||||
if (method_exists($this->mailable, 'withUnsubscribeLink')) {
|
||||
$unsubscribeLink = route('unsubscribe', ['email' => $sentEmail->id]);
|
||||
$this->mailable->withUnsubscribeLink($unsubscribeLink);
|
||||
}
|
||||
|
||||
Mail::to($this->to)->send($this->mailable);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user