mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-17 11:04:07 -08:00
99 lines
2.9 KiB
PHP
99 lines
2.9 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Mail;
|
||
|
|
||
|
use App\Models\Accessory;
|
||
|
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 CheckoutAccessoryMail extends Mailable
|
||
|
{
|
||
|
use Queueable, SerializesModels;
|
||
|
|
||
|
/**
|
||
|
* Create a new message instance.
|
||
|
*/
|
||
|
public function __construct(Accessory $accessory, $checkedOutTo, User $checkedOutBy,$note, $acceptance)
|
||
|
{
|
||
|
$this->item = $accessory;
|
||
|
$this->admin = $checkedOutBy;
|
||
|
$this->note = $note;
|
||
|
$this->checkout_qty = $accessory->checkout_qty;
|
||
|
$this->target = $checkedOutTo;
|
||
|
$this->acceptance = $acceptance;
|
||
|
$this->settings = Setting::getSettings();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get the message envelope.
|
||
|
*/
|
||
|
public function envelope(): Envelope
|
||
|
{
|
||
|
$from = null;
|
||
|
$cc = [];
|
||
|
|
||
|
if (!empty(Setting::getSettings()->alert_email)) {
|
||
|
$from = new Address(Setting::getSettings()->alert_email);
|
||
|
}
|
||
|
if (!empty(Setting::getSettings()->admin_cc_email)) {
|
||
|
$cc[] = new Address(Setting::getSettings()->admin_cc_email);
|
||
|
}
|
||
|
return new Envelope(
|
||
|
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
||
|
cc: $cc,
|
||
|
subject: (trans('mail.Accessory_Checkout_Notification')),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get the message content definition.
|
||
|
*/
|
||
|
public function content(): Content
|
||
|
{
|
||
|
Log::debug($this->item->getImageUrl());
|
||
|
$eula = $this->item->getEula();
|
||
|
$req_accept = $this->item->requireAcceptance();
|
||
|
|
||
|
$accept_url = is_null($this->acceptance) ? null : route('account.accept.item', $this->acceptance);
|
||
|
|
||
|
// Check if the item has custom fields associated with it
|
||
|
if (($this->item->model) && ($this->item->model->fieldset)) {
|
||
|
$fields = $this->item->model->fieldset->fields;
|
||
|
}
|
||
|
|
||
|
$accept_url = is_null($this->acceptance) ? null : route('account.accept.item', $this->acceptance);
|
||
|
|
||
|
return new Content(
|
||
|
markdown: 'mail.markdown.checkout-accessory',
|
||
|
with: [
|
||
|
'item' => $this->item,
|
||
|
'admin' => $this->admin,
|
||
|
'note' => $this->note,
|
||
|
'target' => $this->target,
|
||
|
'eula' => $eula,
|
||
|
'req_accept' => $req_accept,
|
||
|
'accept_url' => $accept_url,
|
||
|
'checkout_qty' => $this->checkout_qty,
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get the attachments for the message.
|
||
|
*
|
||
|
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||
|
*/
|
||
|
public function attachments(): array
|
||
|
{
|
||
|
return [];
|
||
|
}
|
||
|
}
|