LeadNotification.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Mail;
  3. /*
  4. * LeadNotification — письмо-уведомление о новой заявке с сайта.
  5. * Отправляется на notify_email формы сразу после сохранения Lead.
  6. * Содержит: название формы, все поля заявки, дата и IP.
  7. */
  8. use App\Models\Lead;
  9. use App\Models\WebForm;
  10. use Illuminate\Bus\Queueable;
  11. use Illuminate\Mail\Mailable;
  12. use Illuminate\Mail\Mailables\Content;
  13. use Illuminate\Mail\Mailables\Envelope;
  14. use Illuminate\Queue\SerializesModels;
  15. class LeadNotification extends Mailable
  16. {
  17. use Queueable, SerializesModels;
  18. public function __construct(
  19. public readonly Lead $lead,
  20. public readonly WebForm $form,
  21. ) {}
  22. public function envelope(): Envelope
  23. {
  24. return new Envelope(
  25. subject: 'Новая заявка: '.$this->form->title,
  26. );
  27. }
  28. public function content(): Content
  29. {
  30. return new Content(
  31. markdown: 'mail.lead-notification',
  32. with: [
  33. 'lead' => $this->lead,
  34. 'form' => $this->form,
  35. ],
  36. );
  37. }
  38. public function attachments(): array
  39. {
  40. return [];
  41. }
  42. }