Deploy Ladill POS / deploy (push) Has been cancelled
Customer-facing outbound mail should appear from the business (organizer, clinic, company, location), not the Ladill product brand.
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\PosSale;
|
|
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;
|
|
|
|
class DigitalReceiptMail extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public function __construct(public PosSale $sale)
|
|
{
|
|
$this->sale->loadMissing(['lines', 'location']);
|
|
}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
$location = $this->sale->location;
|
|
// Receipt From is the store/location, never the Ladill POS product brand.
|
|
$fromName = trim((string) ($location?->receipt_header ?: $location?->name ?: '')) ?: 'Receipt';
|
|
|
|
return new Envelope(
|
|
from: new Address(
|
|
(string) config('mail.from.address', 'receipts@ladill.com'),
|
|
$fromName,
|
|
),
|
|
subject: 'Your receipt '.$this->sale->reference.' from '.$fromName,
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
view: 'emails.digital-receipt',
|
|
with: [
|
|
'sale' => $this->sale,
|
|
'location' => $this->sale->location,
|
|
],
|
|
);
|
|
}
|
|
}
|