89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\Order as ModelsOrder;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class Order extends Mailable
|
|
{
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
/**
|
|
* The order instance.
|
|
*
|
|
* @var ModelsOrder
|
|
*/
|
|
protected $order;
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(ModelsOrder $order)
|
|
{
|
|
$this->order = $order;
|
|
}
|
|
|
|
/**
|
|
* Build the message.
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function build()
|
|
{
|
|
return $this
|
|
->subject(__('Votre commande Le Gaulois'))
|
|
->view('emails.order')
|
|
->text('emails.order-plain')
|
|
->with('order', $this->order)
|
|
->attachData(
|
|
$this->makePdfFile(),
|
|
sprintf('commande_le_gaulois_%s.pdf', date('Y-m-d H:i:s')),
|
|
['mime' => 'application/pdf']
|
|
);
|
|
}
|
|
|
|
protected function makePdfFile(): string
|
|
{
|
|
/** @var \Meneses\LaravelMpdf\LaravelMpdfWrapper */
|
|
$mpdf = app('laravel-mpdf');
|
|
/** @var \Meneses\LaravelMpdf\LaravelMpdf */
|
|
$pdf = $mpdf->loadView(
|
|
'documents.order',
|
|
$this->order->exportToOrderMailData(),
|
|
[],
|
|
[
|
|
'mode' => '',
|
|
'format' => 'A4',
|
|
'default_font_size' => '12',
|
|
'default_font' => 'sans-serif',
|
|
'margin_left' => 0,
|
|
'margin_right' => 0,
|
|
'margin_top' => 0,
|
|
'margin_bottom' => 0,
|
|
'margin_header' => 0,
|
|
'margin_footer' => 0,
|
|
'orientation' => 'P',
|
|
'title' => __('Commande Le Gaulois'),
|
|
'author' => 'Le Gaulois',
|
|
'watermark' => '',
|
|
'show_watermark' => false,
|
|
'watermark_font' => 'sans-serif',
|
|
'display_mode' => 'fullpage',
|
|
'watermark_text_alpha' => 0.1,
|
|
'custom_font_dir' => '',
|
|
'custom_font_data' => [],
|
|
'auto_language_detection' => false,
|
|
'temp_dir' => rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR),
|
|
'pdfa' => false,
|
|
'pdfaauto' => false,
|
|
]
|
|
);
|
|
return $pdf->output();
|
|
}
|
|
}
|