You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[9.x] Make Illuminate\Mail\Mailable macroable (#40631)
This PR makes the \Illuminate\Mail\Mailable class macroable. A simple use-case is abstracting the options array when having multiple Mailables that you want to attach raw pdf data to:
```php
// Current:
Mail::send((new MyMail())->attachData($pdfData, 'filename.pdf', [
'mime' => 'application/pdf',
]));
// Proposal:
Mailable::macro('attachPdfData', function ($data, $name) {
return $this->attachData($data, $name, [
'mime' => 'application/pdf',
]);
});
Mail::send((new MyMail())->attachPdfData($pdfData, 'filename.pdf'));
```
0 commit comments