|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Mail; |
| 4 | + |
| 5 | +use AllowDynamicProperties; |
| 6 | +use Illuminate\Bus\Queueable; |
| 7 | +use Illuminate\Contracts\Queue\ShouldQueue; |
| 8 | +use Illuminate\Mail\Mailable; |
| 9 | +use Illuminate\Mail\Mailables\Address; |
| 10 | +use Illuminate\Mail\Mailables\Content; |
| 11 | +use Illuminate\Mail\Mailables\Envelope; |
| 12 | +use Illuminate\Queue\SerializesModels; |
| 13 | + |
| 14 | +#[AllowDynamicProperties] class InventoryAlertMail extends Mailable |
| 15 | +{ |
| 16 | + use Queueable, SerializesModels; |
| 17 | + |
| 18 | + /** |
| 19 | + * Create a new message instance. |
| 20 | + */ |
| 21 | + public function __construct($items, $threshold) |
| 22 | + { |
| 23 | + $this->items = $items; |
| 24 | + $this->threshold = $threshold; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Get the message envelope. |
| 29 | + */ |
| 30 | + public function envelope(): Envelope |
| 31 | + { |
| 32 | + $from = new Address(config('mail.from.address'), config('mail.from.name')); |
| 33 | + |
| 34 | + return new Envelope( |
| 35 | + from: $from, |
| 36 | + subject: trans('mail.Low_Inventory_Report'), |
| 37 | + ); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Get the message content definition. |
| 42 | + */ |
| 43 | + public function content(): Content |
| 44 | + { |
| 45 | + return new Content( |
| 46 | + markdown: 'notifications.markdown.report-low-inventory', |
| 47 | + with: [ |
| 48 | + 'items' => $this->items, |
| 49 | + 'threshold' => $this->threshold, |
| 50 | + ] |
| 51 | + ); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Get the attachments for the message. |
| 56 | + * |
| 57 | + * @return array<int, \Illuminate\Mail\Mailables\Attachment> |
| 58 | + */ |
| 59 | + public function attachments(): array |
| 60 | + { |
| 61 | + return []; |
| 62 | + } |
| 63 | +} |
0 commit comments