-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added InvoiceMail Mailable for sending invoi
- Loading branch information
1 parent
0cb5d52
commit ef731cb
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Mail; | ||
|
||
use App\Models\Invoice; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Mail\Mailable; | ||
use Illuminate\Queue\SerializesModels; | ||
use Barryvdh\DomPDF\Facade as PDF; | ||
|
||
class InvoiceMail extends Mailable | ||
{ | ||
use Queueable, SerializesModels; | ||
|
||
public $invoice; | ||
|
||
public function __construct(Invoice $invoice) | ||
{ | ||
$this->invoice = $invoice; | ||
} | ||
|
||
public function build() | ||
{ | ||
$pdf = PDF::loadView('invoices.pdf', ['invoice' => $this->invoice]); | ||
|
||
return $this->subject('Your Invoice from Ecommerce') | ||
->view('emails.invoice') | ||
->attachData($pdf->output(), "invoice-{$this->invoice->id}.pdf", [ | ||
'mime' => 'application/pdf', | ||
]); | ||
} | ||
} |