| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
-
- namespace App\Mail;
-
- use App\Models\Order;
- use Illuminate\Bus\Queueable;
- use Illuminate\Mail\Mailable;
- use Illuminate\Mail\Mailables\Address;
- use Illuminate\Mail\Mailables\Content;
- use Illuminate\Mail\Mailables\Envelope;
- use Illuminate\Queue\SerializesModels;
-
- /**
- * Sent to the shopper once their order is paid. Written in the store's language.
- */
- class OrderConfirmation extends Mailable
- {
- use Queueable, SerializesModels;
-
- public function __construct(public Order $order) {}
-
- public function envelope(): Envelope
- {
- $store = $this->order->store;
-
- return new Envelope(
- // Sent from our address (so it is delivered), but under the store's name, with replies going to the store.
- from: new Address((string) config('mail.from.address'), $store->name),
- replyTo: $store->contact_email !== null ? [new Address($store->contact_email, $store->name)] : [],
- subject: $store->language->value === 'ms'
- ? "Pesanan #{$this->order->number} disahkan - {$store->name}"
- : "Order #{$this->order->number} confirmed - {$store->name}",
- );
- }
-
- public function content(): Content
- {
- $store = $this->order->store;
- $brand = StoreBrand::for($store);
-
- return new Content(
- // In the store's own colours, fonts and corners, so shoppers see the shop they bought from.
- view: 'mail.orders.confirmation',
- text: 'mail.orders.confirmation-text',
- with: [
- 'order' => $this->order->loadMissing('items'),
- 'store' => $store,
- 'brand' => $brand,
- 'orderUrl' => $brand->orderUrl($this->order),
- 'whatsappUrl' => $brand->whatsappUrl($this->order),
- ],
- );
- }
- }
|