空间
laravel-pdf
v2.6.0 adds the
Attachable
contract support to
PdfBuilder
, so you can pass a generated PDF directly to
attach()
in a mailable or notification without saving it to disk first.
PdfBuilder
now implements
Illuminate\Contracts\Mail\Attachable
, which means any
PdfBuilder
instance works wherever Laravel expects an attachable. The filename comes from
name()
(the
.pdf
extension is appended automatically if missing) and the MIME type is set to
application/pdf
自动地。
Here's how it looks in a notification:
使用
照亮\通知\消息\邮件消息
;使用
空间\LaravelPdf\立面\Pdf
;民众
功能
到邮箱
(
目的
$notifiable)
:
邮件信息{$pdf
=
PDF
::
看法
(
'pdfs.invoice'
,[
'发票'
=>
$this
->
invoice])
->
姓名
(
'invoice.pdf'
(英文):
返回
(
新的
邮件信息
)
->
主题
(
'Your invoice'
)
->
线
(
'Please find your invoice attached.'
)
->
附
($pdf);}
And in a mailable via
attachments()
:
使用
Illuminate\Mail\Mailable
;使用
空间\LaravelPdf\立面\Pdf
;班级
发票邮件
延伸
可邮寄{
民众
功能
__构造
(
民众
发票
$invoice) {}
民众
功能
附件
()
:
大批{
返回
[
PDF
::
看法
(
'pdfs.invoice'
,[
'发票'
=>
$this
->
invoice])
->
姓名
(
'invoice.pdf'
),];}}




