Move email/ resources to mail/, added invoice generated email to admin, updated email template
This commit is contained in:
@@ -2,21 +2,20 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Site;
|
||||
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 Illuminate\Support\Facades\Config;
|
||||
|
||||
use App\Models\Invoice;
|
||||
|
||||
class InvoiceEmail extends Mailable
|
||||
class InvoiceEmail extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $invoice;
|
||||
public $site;
|
||||
protected Invoice $io;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
@@ -25,28 +24,33 @@ class InvoiceEmail extends Mailable
|
||||
*/
|
||||
public function __construct(Invoice $o)
|
||||
{
|
||||
$this->invoice = $o;
|
||||
$this->io = $o;
|
||||
$this->queue = 'user';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function build()
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
Config::set('site',Site::findOrFail($this->invoice->site_id));
|
||||
$this->site = config('site');
|
||||
return new Envelope(
|
||||
subject: sprintf('Invoice %d for services, due %s',
|
||||
$this->io->lid,
|
||||
$this->io->due_at->format('Y-m-d')),
|
||||
);
|
||||
}
|
||||
|
||||
return $this
|
||||
->markdown('email.user.invoice',['site'=>config('site')])
|
||||
->subject(sprintf( 'Invoice: %s - Total: $%s - Due: %s',
|
||||
$this->invoice->id,
|
||||
number_format($this->invoice->total,2),
|
||||
$this->invoice->due_at->format('Y-m-d')))
|
||||
->with([
|
||||
'user'=>$this->invoice->account->user,
|
||||
'site'=>$this->invoice->account->user->site,
|
||||
]);
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
markdown: 'mail.invoice',
|
||||
with: [
|
||||
'io'=>$this->io,
|
||||
'site'=>$this->io->site,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user