Skip to content

A free open source IT asset/license management system

Accept $firstTimeSending in mails

Marcus Moore7423d13bddd2
diff --git a/app/Mail/CheckoutAccessoryMail.php b/app/Mail/CheckoutAccessoryMail.php
index e5aaa44662..f48236d0ae 100644
--- a/app/Mail/CheckoutAccessoryMail.php
+++ b/app/Mail/CheckoutAccessoryMail.php
@@ -18,10 +18,12 @@ class CheckoutAccessoryMail extends BaseMailable
{
use Queueable, SerializesModels;
+ private bool $firstTimeSending;
+
/**
* Create a new message instance.
*/
- public function __construct(Accessory $accessory, $checkedOutTo, User $checkedOutBy, $acceptance, $note)
+ public function __construct(Accessory $accessory, $checkedOutTo, User $checkedOutBy, $acceptance, $note, bool $firstTimeSending = true)
{
$this->item = $accessory;
$this->admin = $checkedOutBy;
@@ -29,6 +31,7 @@ class CheckoutAccessoryMail extends BaseMailable
$this->checkout_qty = $accessory->checkout_qty;
$this->target = $checkedOutTo;
$this->acceptance = $acceptance;
+ $this->firstTimeSending = $firstTimeSending;
$this->settings = Setting::getSettings();
}
@@ -41,7 +44,7 @@ class CheckoutAccessoryMail extends BaseMailable
return new Envelope(
from: $from,
- subject: trans_choice('mail.Accessory_Checkout_Notification', $this->checkout_qty),
+ subject: $this->getSubject(),
);
}
@@ -113,4 +116,13 @@ class CheckoutAccessoryMail extends BaseMailable
{
return [];
}
+
+ private function getSubject(): string
+ {
+ if ($this->firstTimeSending) {
+ return trans_choice('mail.Accessory_Checkout_Notification', $this->checkout_qty);
+ }
+
+ return trans('mail.unaccepted_asset_reminder');
+ }
}
diff --git a/app/Mail/CheckoutConsumableMail.php b/app/Mail/CheckoutConsumableMail.php
index 4d2cf7bd75..76d0a12145 100644
--- a/app/Mail/CheckoutConsumableMail.php
+++ b/app/Mail/CheckoutConsumableMail.php
@@ -15,10 +15,12 @@ class CheckoutConsumableMail extends BaseMailable
{
use Queueable, SerializesModels;
+ private bool $firstTimeSending;
+
/**
* Create a new message instance.
*/
- public function __construct(Consumable $consumable, $checkedOutTo, User $checkedOutBy, $acceptance, $note)
+ public function __construct(Consumable $consumable, $checkedOutTo, User $checkedOutBy, $acceptance, $note, bool $firstTimeSending = true)
{
$this->item = $consumable;
$this->admin = $checkedOutBy;
@@ -26,6 +28,7 @@ class CheckoutConsumableMail extends BaseMailable
$this->target = $checkedOutTo;
$this->acceptance = $acceptance;
$this->qty = $consumable->checkout_qty;
+ $this->firstTimeSending = $firstTimeSending;
$this->settings = Setting::getSettings();
}
@@ -39,7 +42,7 @@ class CheckoutConsumableMail extends BaseMailable
return new Envelope(
from: $from,
- subject: trans('mail.Confirm_consumable_delivery'),
+ subject: $this->getSubject(),
);
}
@@ -78,4 +81,13 @@ class CheckoutConsumableMail extends BaseMailable
{
return [];
}
+
+ private function getSubject(): string
+ {
+ if ($this->firstTimeSending) {
+ return trans('mail.Confirm_consumable_delivery');
+ }
+
+ return trans('mail.unaccepted_asset_reminder');
+ }
}
diff --git a/app/Mail/CheckoutLicenseMail.php b/app/Mail/CheckoutLicenseMail.php
index 91a8faa30a..69c439b623 100644
--- a/app/Mail/CheckoutLicenseMail.php
+++ b/app/Mail/CheckoutLicenseMail.php
@@ -16,10 +16,12 @@ class CheckoutLicenseMail extends BaseMailable
{
use Queueable, SerializesModels;
+ private bool $firstTimeSending;
+
/**
* Create a new message instance.
*/
- public function __construct(LicenseSeat $licenseSeat, $checkedOutTo, User $checkedOutBy, $acceptance, $note)
+ public function __construct(LicenseSeat $licenseSeat, $checkedOutTo, User $checkedOutBy, $acceptance, $note, bool $firstTimeSending = true)
{
$this->item = $licenseSeat;
$this->admin = $checkedOutBy;
@@ -27,6 +29,7 @@ class CheckoutLicenseMail extends BaseMailable
$this->acceptance = $acceptance;
$this->settings = Setting::getSettings();
$this->target = $checkedOutTo;
+ $this->firstTimeSending = $firstTimeSending;
if($this->target instanceof User){
$this->target = $this->target->display_name;
@@ -45,7 +48,7 @@ class CheckoutLicenseMail extends BaseMailable
return new Envelope(
from: $from,
- subject: trans('mail.Confirm_license_delivery'),
+ subject: $this->getSubject(),
);
}
@@ -82,4 +85,13 @@ class CheckoutLicenseMail extends BaseMailable
{
return [];
}
+
+ private function getSubject(): string
+ {
+ if ($this->firstTimeSending) {
+ return trans('mail.Confirm_license_delivery');
+ }
+
+ return trans('mail.unaccepted_asset_reminder');
+ }
}