2024-10-16 15:53:05 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Mail;
|
|
|
|
|
|
|
|
use App\Models\Consumable;
|
|
|
|
use App\Models\Setting;
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Mail\Mailable;
|
|
|
|
use Illuminate\Mail\Mailables\Address;
|
|
|
|
use Illuminate\Mail\Mailables\Content;
|
|
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class CheckoutConsumableMail extends Mailable
|
|
|
|
{
|
|
|
|
use Queueable, SerializesModels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new message instance.
|
|
|
|
*/
|
|
|
|
public function __construct(Consumable $consumable, $checkedOutTo, User $checkedOutBy, $acceptance, $note)
|
|
|
|
{
|
|
|
|
$this->item = $consumable;
|
|
|
|
$this->admin = $checkedOutBy;
|
|
|
|
$this->note = $note;
|
|
|
|
$this->target = $checkedOutTo;
|
|
|
|
$this->acceptance = $acceptance;
|
2024-10-23 15:05:39 -07:00
|
|
|
$this->qty = $consumable->checkout_qty;
|
2024-10-16 15:53:05 -07:00
|
|
|
|
|
|
|
$this->settings = Setting::getSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the message envelope.
|
|
|
|
*/
|
|
|
|
public function envelope(): Envelope
|
|
|
|
{
|
2024-10-23 15:43:42 -07:00
|
|
|
$from = new Address(env('MAIL_FROM_ADDR','service@snipe-it.io'));
|
2024-10-16 15:53:05 -07:00
|
|
|
|
|
|
|
return new Envelope(
|
2024-10-23 14:44:45 -07:00
|
|
|
from: $from,
|
2024-10-16 15:53:05 -07:00
|
|
|
subject: trans('mail.Confirm_consumable_delivery'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the message content definition.
|
|
|
|
*/
|
|
|
|
public function content(): Content
|
|
|
|
{
|
2024-10-23 15:05:39 -07:00
|
|
|
|
2024-10-16 15:53:05 -07:00
|
|
|
$eula = $this->item->getEula();
|
|
|
|
$req_accept = $this->item->requireAcceptance();
|
|
|
|
|
|
|
|
$accept_url = is_null($this->acceptance) ? null : route('account.accept.item', $this->acceptance);
|
|
|
|
|
|
|
|
return new Content(
|
|
|
|
markdown: 'mail.markdown.checkout-consumable',
|
|
|
|
with: [
|
|
|
|
'item' => $this->item,
|
|
|
|
'admin' => $this->admin,
|
|
|
|
'note' => $this->note,
|
|
|
|
'target' => $this->target,
|
|
|
|
'eula' => $eula,
|
|
|
|
'req_accept' => $req_accept,
|
|
|
|
'accept_url' => $accept_url,
|
2024-10-23 15:05:39 -07:00
|
|
|
'qty' => $this->qty,
|
2024-10-16 15:53:05 -07:00
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the attachments for the message.
|
|
|
|
*
|
|
|
|
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
|
|
|
*/
|
|
|
|
public function attachments(): array
|
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|