Files
ladill-pos/app/Mail/DigitalReceiptMail.php
T
isaacclad 8e4ee71788
Deploy Ladill POS / deploy (push) Has been cancelled
fix(email): use client/org name as From display, not Ladill product
Customer-facing outbound mail should appear from the business (organizer,
clinic, company, location), not the Ladill product brand.
2026-07-16 12:01:35 +00:00

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,
],
);
}
}