This commit is contained in:
Andras Bacsai
2023-07-28 10:55:26 +02:00
parent e9bd1f88c0
commit 7e4b1a8f8f
30 changed files with 198 additions and 95 deletions

View File

@@ -11,13 +11,13 @@ class EmailChannel
public function send(SendsEmail $notifiable, Notification $notification): void
{
$this->bootConfigs($notifiable);
ray($notification);
$recepients = $notifiable->getRecepients($notification);
$bcc = $notifiable->routeNotificationForEmail('test_recipients');
if (count($bcc) === 0) {
if ($notifiable instanceof \App\Models\Team) {
$bcc = $notifiable->members()->pluck('email')->toArray();
}
if (count($recepients) === 0) {
throw new \Exception('No email recipients found');
}
$mailMessage = $notification->toMail($notifiable);
Mail::send(
[],
@@ -27,7 +27,7 @@ class EmailChannel
data_get($notifiable, 'smtp_from_address'),
data_get($notifiable, 'smtp_from_name'),
)
->bcc($bcc)
->bcc($recepients)
->subject($mailMessage->subject)
->html((string)$mailMessage->render())
);

View File

@@ -4,5 +4,5 @@ namespace App\Notifications\Channels;
interface SendsEmail
{
public function routeNotificationForEmail();
}
public function getRecepients($notification);
}