osb/app/Mail/InvoiceEmail.php
Deon George 814e107327
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 9s
Temporarily fix invoice emailing
2024-07-06 10:28:45 +10:00

52 lines
1.0 KiB
PHP

<?php
namespace App\Mail;
use App\Models\Site;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Config;
use App\Models\Invoice;
class InvoiceEmail extends Mailable
{
use Queueable, SerializesModels;
public $invoice;
public $site;
/**
* Create a new message instance.
*
* @param Invoice $o
*/
public function __construct(Invoice $o)
{
$this->invoice = $o;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
Config::set('site',Site::findOrFail($this->invoice->site_id));
$this->site = config('site');
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,
]);
}
}