osb/app/Mail/InvoiceEmail.php

60 lines
1.1 KiB
PHP
Raw Normal View History

2020-05-25 07:45:17 +00:00
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
2020-05-25 07:45:17 +00:00
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
2020-05-25 07:45:17 +00:00
use Illuminate\Queue\SerializesModels;
2024-09-19 08:45:46 +00:00
use App\Models\{Invoice,User};
2020-05-25 07:45:17 +00:00
class InvoiceEmail extends Mailable implements ShouldQueue
2020-05-25 07:45:17 +00:00
{
use Queueable, SerializesModels;
protected Invoice $io;
2020-05-25 07:45:17 +00:00
/**
* Create a new message instance.
*
* @param Invoice $o
*/
public function __construct(Invoice $o)
{
$this->io = $o;
$this->queue = 'user';
2020-05-25 07:45:17 +00:00
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
2024-09-19 08:45:46 +00:00
// Send an email to an admin that the invoice was created
$uo = User::where('email',config('osb.admin'))->sole();
return new Envelope(
2024-09-19 08:45:46 +00:00
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.
2020-05-25 07:45:17 +00:00
*/
public function content(): Content
2020-05-25 07:45:17 +00:00
{
return new Content(
markdown: 'mail.invoice',
with: [
'io'=>$this->io,
'site'=>$this->io->site,
]
);
2020-05-25 07:45:17 +00:00
}
}