After updating the mailcoach package from version 2.21.0 to 2.22.0 and even the lastest 2.23.5, I am not able to access the campaign model in my custom mailable. Did something change? Now, $this->campaign returns null.
<?php
namespace App\Mail;
use App\EmailAttachment;
use Spatie\Mailcoach\Mails\CampaignMail;
class ClassMessage extends CampaignMail
{
public $emailContent;
public function build()
{
$this->emailContent = $this->campaign->html;
$this
->from(
$this->campaign->from_email ?? $this->campaign->emailList->default_from_email,
$this->campaign->from_name ?? $this->campaign->emailList->default_from_name ?? null
)
->subject($this->subject)
->view('emails.classes.message')
->addUnsubscribeHeaders()
->storeTransportMessageId();
foreach (EmailAttachment::query()->where('campaign_id', $this->campaign->id)->get() as $attachment) {
$this->attachFromStorage($attachment->source);
}
return $this;
}
}
After updating the mailcoach package from version
2.21.0
to2.22.0
and even the lastest2.23.5
, I am not able to access thecampaign
model in my custom mailable. Did something change? Now,$this->campaign
returnsnull
.