Files
ladill-pos/app/Mail/DigitalReceiptMail.php
T
isaacclad 600aedb59d
Deploy Ladill POS / deploy (push) Successful in 31s
Email digital receipts, add promo settings, and apply tips at charge.
Send real receipt emails from the customer display and sale page, store
branch promo content for the idle screen, and fold selected tips into totals.
2026-07-15 16:10:20 +00:00

49 lines
1.2 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;
$fromName = $location?->receipt_header
?: $location?->name
?: (string) config('mail.from.name', 'Ladill POS');
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,
],
);
}
}