83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications\Order;
|
|
|
|
use App\Models\Shop\Order;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class OrderCreated extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* Order
|
|
*
|
|
* @var \App\Models\Shop\Order
|
|
*/
|
|
private $order;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*
|
|
* @param \App\Models\Shop\Order $order
|
|
* @return void
|
|
*/
|
|
public function __construct(Order $order)
|
|
{
|
|
$this->order = $order;
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
|
*/
|
|
public function via($notifiable)
|
|
{
|
|
// phpcs:enable
|
|
return ['mail'];
|
|
}
|
|
|
|
/**
|
|
* Get the mail representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
|
*/
|
|
public function toMail($notifiable)
|
|
{
|
|
// phpcs:enable
|
|
return (new MailMessage())
|
|
->subject(\trans('Votre nouvelle commande - :appname', ['appname' => \config('app.name')]))
|
|
->greeting(trans('Votre commande avec pour référence :ref à bien été enregistrée', [
|
|
'ref' => $this->order->reference
|
|
]))
|
|
->line(\trans('Dès qu\'elle aura été validée, vous en serez notifié et une facture vous sera adressée.'))
|
|
->action(
|
|
\trans(
|
|
'Vous pouvez également consulter l\'avancement de votre commande dans votre espace sur la boutique.'
|
|
),
|
|
\route('account.order-detail', ['reference' => $this->order->reference])
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
|
*/
|
|
public function toArray($notifiable)
|
|
{
|
|
// phpcs:enable
|
|
return [
|
|
'order_id' => $this->order->id
|
|
];
|
|
}
|
|
}
|