2020-05-25 07:45:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Mail;
|
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
2021-09-29 06:20:22 +00:00
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
2020-05-25 07:45:17 +00:00
|
|
|
use Illuminate\Mail\Mailable;
|
2024-08-03 00:06:25 +00:00
|
|
|
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
|
|
|
|
2024-08-03 00:06:25 +00:00
|
|
|
class InvoiceEmail extends Mailable implements ShouldQueue
|
2020-05-25 07:45:17 +00:00
|
|
|
{
|
|
|
|
use Queueable, SerializesModels;
|
|
|
|
|
2024-08-03 00:06:25 +00:00
|
|
|
protected Invoice $io;
|
2020-05-25 07:45:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new message instance.
|
|
|
|
*
|
|
|
|
* @param Invoice $o
|
|
|
|
*/
|
|
|
|
public function __construct(Invoice $o)
|
|
|
|
{
|
2024-08-03 00:06:25 +00:00
|
|
|
$this->io = $o;
|
|
|
|
$this->queue = 'user';
|
2020-05-25 07:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-08-03 00:06:25 +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();
|
|
|
|
|
2024-08-03 00:06:25 +00:00
|
|
|
return new Envelope(
|
2024-09-19 08:45:46 +00:00
|
|
|
bcc: $uo->email,
|
2024-08-03 00:06:25 +00:00
|
|
|
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
|
|
|
*/
|
2024-08-03 00:06:25 +00:00
|
|
|
public function content(): Content
|
2020-05-25 07:45:17 +00:00
|
|
|
{
|
2024-08-03 00:06:25 +00:00
|
|
|
return new Content(
|
|
|
|
markdown: 'mail.invoice',
|
|
|
|
with: [
|
|
|
|
'io'=>$this->io,
|
|
|
|
'site'=>$this->io->site,
|
|
|
|
]
|
|
|
|
);
|
2020-05-25 07:45:17 +00:00
|
|
|
}
|
|
|
|
}
|