onQueue('emails'); } abstract protected function emailType(): DripEmailType; abstract protected function buildMail(): Mailable; /** * Per-email eligibility checks beyond the shared "can receive" and * "not already sent" guards. */ protected function shouldSend(): bool { return true; } public function handle(): void { if (! $this->user->canReceiveEmails()) { return; } if ($this->user->hasReceivedEmail($this->emailType())) { return; } if (! $this->shouldSend()) { return; } Mail::to($this->user)->send($this->buildMail()); UserMailLog::create([ 'user_id' => $this->user->id, 'email_type' => $this->emailType(), 'email_identifier' => $this->emailType()->value, 'sent_at' => now(), ]); } }