Move email/ resources to mail/, added invoice generated email to admin, updated email template
This commit is contained in:
@@ -52,7 +52,7 @@ class CancelRequest extends Mailable
|
||||
}
|
||||
|
||||
return $this
|
||||
->markdown('email.admin.service.cancel')
|
||||
->markdown('mail.admin.service.cancel')
|
||||
->subject($subject)
|
||||
->with(['site'=>$this->service->site]);
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ class ChangeRequest extends Mailable
|
||||
}
|
||||
|
||||
return $this
|
||||
->markdown('email.admin.service.change')
|
||||
->markdown('mail.admin.service.change')
|
||||
->subject($subject)
|
||||
->with(['site'=>$this->service->site]);
|
||||
}
|
||||
|
@@ -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,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
57
app/Mail/InvoiceGeneratedAdmin.php
Normal file
57
app/Mail/InvoiceGeneratedAdmin.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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;
|
||||
|
||||
class InvoiceGeneratedAdmin 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 = 'admin';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: sprintf('Invoice %d generated for %s, due %s',
|
||||
$this->io->lid,
|
||||
$this->io->account->name,
|
||||
$this->io->due_at->format('Y-m-d')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
markdown: 'mail.admin.invoice.generated',
|
||||
with: [
|
||||
'io'=>$this->io,
|
||||
'site'=>$this->io->site,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
@@ -52,7 +52,7 @@ class OrderRequest extends Mailable
|
||||
}
|
||||
|
||||
return $this
|
||||
->markdown('email.admin.order.approve')
|
||||
->markdown('mail.admin.order.approve')
|
||||
->subject($subject)
|
||||
->with(['site'=>$this->service->site]);
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ class OrderRequestApprove extends Mailable
|
||||
}
|
||||
|
||||
return $this
|
||||
->markdown('email.admin.order.approve')
|
||||
->markdown('mail.admin.order.approve')
|
||||
->subject($subject)
|
||||
->with(['site'=>$this->so->site]);
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ class OrderRequestReject extends Mailable
|
||||
Config::set('site',$this->service->site);
|
||||
|
||||
return $this
|
||||
->markdown('email.admin.order.reject')
|
||||
->markdown('mail.admin.order.reject')
|
||||
->subject(sprintf('Your order: #%s was rejected',$this->service->id))
|
||||
->with(['site'=>$this->service->site]);
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ class SocialLink extends Mailable
|
||||
Config::set('site',$this->site);
|
||||
|
||||
return $this
|
||||
->markdown('email.system.social_link')
|
||||
->markdown('mail.system.social_link')
|
||||
->subject('Link your Account')
|
||||
->with([
|
||||
'site'=>$this->site,
|
||||
|
@@ -36,7 +36,7 @@ class TestEmail extends Mailable
|
||||
Config::set('site',$this->user->site);
|
||||
|
||||
return $this
|
||||
->markdown('email.system.test_email')
|
||||
->markdown('mail.system.test_email')
|
||||
->subject('Just a test...')
|
||||
->with([
|
||||
'site'=>$this->user->site,
|
||||
|
@@ -39,7 +39,7 @@ class TrafficMismatch extends Mailable
|
||||
Config::set('site',$x=Site::find(1)); // @todo To auto determine;
|
||||
|
||||
return $this
|
||||
->markdown('email.system.broadband_traffic_mismatch')
|
||||
->markdown('mail.system.broadband_traffic_mismatch')
|
||||
->subject('Traffic Mismatch for '.$this->date)
|
||||
->with([
|
||||
'site'=>$x,
|
||||
|
Reference in New Issue
Block a user