File: D:/HostingSpaces/blijegasten/blijegasten.be/app/Komma/Shop/Orders/Mail/OrderPayLaterCustomer.php
<?php
namespace App\Komma\Shop\Orders\Mail;
use App\Komma\Globalization\RegionInfo;
use App\Komma\Globalization\RegionInfoInterface;
use App\Komma\Shop\Invoicing\InvoiceService;
use App\Komma\Shop\Orders\Models\Order;
use App\Komma\Shop\Orders\OrderStatus;
use App\Komma\Users\Genders;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\URL;
/**
* Class OrderStatusUpdatedCustomer
*
* A mail telling a customer that his order was updated
*
* @package App\Komma\Shop\Orders\Mail
*/
class OrderPayLaterCustomer extends Mailable
{
use Queueable, SerializesModels;
/** @var Order $order */
private $order;
/** @var InvoiceService */
private $invoiceService;
/** @var RegionInfo */
private $regionInfo;
/**
* Create a new message instance.
*
* @param Order $order
* @see OrderStatus
*/
public function __construct(Order $order)
{
$this->invoiceService = app(InvoiceService::class);
$this->order = $order;
$this->regionInfo = app(RegionInfoInterface::class);
// Set the country model
$this->order->invoice_country = $this->regionInfo::getInstance($this->order->invoice_country_iso2);
if(!empty($this->order->shipping_country_iso2)) $this->order->shipping_country = $this->regionInfo::getInstance($this->order->shipping_country_iso2);
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$payLaterUrl = URL::signedRoute('transaction.payLater', ['order' => $this->order->id]);
$this->subject(__('shop/orders.mail.pay_later.subject'));
//Prepare mail view data
$data = [
'order' => $this->order,
'showReceipt' => true,
'subject' => __('shop/orders.mail.pay_later.subject'),
'regionInfo' => $this->regionInfo,
'button_text' => __('shop/orders.mail.pay_later.button_text'),
'button_url' => $payLaterUrl
];
//Create the view and add attachments if needed
$view = $this->view('emails.shop.orderPayLaterCustomer', $data);
return $view;
}
}