Flesh out mail contents
This commit is contained in:
@@ -346,6 +346,7 @@ class AcceptanceController extends Controller
|
||||
|
||||
if ($recipient) {
|
||||
Mail::to($recipient)->send(new CheckoutAcceptanceResponseMail(
|
||||
$acceptance,
|
||||
$recipient,
|
||||
$request->input('asset_acceptance') === 'accepted'
|
||||
));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\CheckoutAcceptance;
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -14,14 +15,16 @@ class CheckoutAcceptanceResponseMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public bool $wasAccepted;
|
||||
public CheckoutAcceptance $acceptance;
|
||||
public User $recipient;
|
||||
public bool $wasAccepted;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct(User $recipient, bool $wasAccepted)
|
||||
public function __construct(CheckoutAcceptance $acceptance, User $recipient, bool $wasAccepted)
|
||||
{
|
||||
$this->acceptance = $acceptance;
|
||||
$this->recipient = $recipient;
|
||||
$this->wasAccepted = $wasAccepted;
|
||||
}
|
||||
@@ -31,8 +34,13 @@ class CheckoutAcceptanceResponseMail extends Mailable
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
// @todo: translate
|
||||
$subject = $this->wasAccepted
|
||||
? 'A checkout you initiated was accepted'
|
||||
: 'A checkout you initiated was declined';
|
||||
|
||||
return new Envelope(
|
||||
subject: 'A checkout you initiated was ' . ($this->wasAccepted ? 'accepted' : 'declined'),
|
||||
subject: $subject,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,12 +52,23 @@ class CheckoutAcceptanceResponseMail extends Mailable
|
||||
return new Content(
|
||||
markdown: 'mail.markdown.checkout-acceptance-response',
|
||||
with: [
|
||||
'assignedTo' => $this->acceptance->assignedTo,
|
||||
'introduction' => $this->introduction(),
|
||||
'item' => $this->acceptance->checkoutable,
|
||||
'note' => $this->acceptance->note,
|
||||
'recipient' => $this->recipient,
|
||||
'wasAccepted' => $this->wasAccepted,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
private function introduction(): string
|
||||
{
|
||||
// @todo: translate
|
||||
return $this->wasAccepted
|
||||
? 'The following was accepted'
|
||||
: 'The following was declined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
@component('mail::message')
|
||||
# {{ trans('mail.hello') }} {{ $recipient->present()->fullName() }},
|
||||
|
||||
{fullName} {accepted|declined} the following checkout:
|
||||
{{ $introduction }}:
|
||||
|
||||
@component('mail::table')
|
||||
| | |
|
||||
| ------------- | ------------- |
|
||||
| **{{ trans('mail.user') }}** | {{ $assignedTo->present()->fullName() }} |
|
||||
@if ((isset($item->name)) && ($item->name!=''))
|
||||
| **{{ trans('mail.name') }}** | {{ $item->name }} |
|
||||
| **{{ trans('mail.name') }}** | {{ $item->name }} |
|
||||
@endif
|
||||
@if (isset($item->asset_tag))
|
||||
| **{{ trans('mail.asset_tag') }}** | {{ $item->asset_tag }} |
|
||||
| **{{ trans('mail.asset_tag') }}** | {{ $item->asset_tag }} |
|
||||
@endif
|
||||
@if (isset($note) && $note != '')
|
||||
| **{{ trans('mail.notes') }}** | {{ $note }} |
|
||||
@if ($note != '')
|
||||
| **{{ trans('mail.notes') }}** | {{ $note }} |
|
||||
@endif
|
||||
@endcomponent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user