osb/app/Mail/InvoiceEmail.php
Deon George 3fc676fa26
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s
BCC invoice emails to the admin
2024-09-19 18:45:46 +10:00

60 lines
1.1 KiB
PHP

<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use App\Models\{Invoice,User};
class InvoiceEmail extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
protected Invoice $io;
/**
* Create a new message instance.
*
* @param Invoice $o
*/
public function __construct(Invoice $o)
{
$this->io = $o;
$this->queue = 'user';
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
// Send an email to an admin that the invoice was created
$uo = User::where('email',config('osb.admin'))->sole();
return new Envelope(
bcc: $uo->email,
subject: sprintf('Invoice %d for services, due %s',
$this->io->lid,
$this->io->due_at->format('Y-m-d')),
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
markdown: 'mail.invoice',
with: [
'io'=>$this->io,
'site'=>$this->io->site,
]
);
}
}