diff --git a/laravel_app/app/Livewire/Forms/MailingForm.php b/laravel_app/app/Livewire/Forms/MailingForm.php index e419e59..e1789f3 100644 --- a/laravel_app/app/Livewire/Forms/MailingForm.php +++ b/laravel_app/app/Livewire/Forms/MailingForm.php @@ -4,6 +4,7 @@ use App\Models\ProjectMailing; use App\Models\ProjectReport; +use Illuminate\Support\Facades\Mail; use Livewire\Attributes\Rule; use Livewire\Form; @@ -46,5 +47,10 @@ public function save() $mailing->recipients()->createMany($this->recipients); $this->setReport($this->report); + + + Mail::to($mailing->recipients()->pluck('email')->toArray()) + ->send(new \App\Mail\ReportMailer($mailing)); + } } diff --git a/laravel_app/app/Mail/ReportMailer.php b/laravel_app/app/Mail/ReportMailer.php index 12fb061..9455a4c 100644 --- a/laravel_app/app/Mail/ReportMailer.php +++ b/laravel_app/app/Mail/ReportMailer.php @@ -26,8 +26,6 @@ class ReportMailer extends Mailable public function __construct(ProjectMailing $mailing) { $this->mailing = $mailing; -// logger($mailing->recipients()->pluck('email')->toArray()); -// $this->to(['martin@sobit.nl', ...($mailing->recipients()->pluck('email')->toArray())]); } /** diff --git a/laravel_app/app/Models/ProjectMailing.php b/laravel_app/app/Models/ProjectMailing.php index 03ce30a..03254a4 100644 --- a/laravel_app/app/Models/ProjectMailing.php +++ b/laravel_app/app/Models/ProjectMailing.php @@ -18,17 +18,6 @@ class ProjectMailing extends Model 'message', ]; - protected static function booted() - { - static::created(function (ProjectMailing $projectMailing) { - $toAddresses = $projectMailing->recipients()->pluck('email')->toArray(); - logger('created'); - logger($projectMailing); - - Mail::to($toAddresses) - ->send(new \App\Mail\ReportMailer($projectMailing)); - }); - } public function addAttachment($name, UploadedFile $file) {