Apply pint to Mail directory

This commit is contained in:
snipe
2026-03-13 17:26:56 +00:00
parent ab7ff30a73
commit de607e7d83
16 changed files with 140 additions and 131 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
<?php
namespace App\Mail;
use Illuminate\Mail\Mailable;
@@ -15,4 +16,4 @@ class BaseMailable extends Mailable
]
);
}
}
}
+4 -4
View File
@@ -77,7 +77,7 @@ class BulkAssetCheckoutMail extends Mailable
{
$this->assets = $this->assets->map(function (Asset $asset) {
$fields = $asset->model?->fieldset?->fields->filter(function (CustomField $field) {
return $field->show_in_email && !$field->field_encrypted;
return $field->show_in_email && ! $field->field_encrypted;
});
$asset->setRelation('fields', $fields);
@@ -97,7 +97,7 @@ class BulkAssetCheckoutMail extends Mailable
private function groupAssetsByCategory(): Collection
{
return $this->assets->groupBy(fn($asset) => $asset->model->category->id);
return $this->assets->groupBy(fn ($asset) => $asset->model->category->id);
}
private function getIntroduction(): string
@@ -111,7 +111,7 @@ class BulkAssetCheckoutMail extends Mailable
private function getRequiresAcceptanceInfo(): ?string
{
if (!$this->requires_acceptance) {
if (! $this->requires_acceptance) {
return null;
}
@@ -120,7 +120,7 @@ class BulkAssetCheckoutMail extends Mailable
private function getRequiresAcceptancePrompt(): ?string
{
if (!$this->requires_acceptance) {
if (! $this->requires_acceptance) {
return null;
}
+7 -6
View File
@@ -7,6 +7,7 @@ use App\Models\Setting;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -47,11 +48,11 @@ class CheckinAccessoryMail extends BaseMailable
{
return new Content(
markdown: 'mail.markdown.checkin-accessory',
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
]
);
}
@@ -59,7 +60,7 @@ class CheckinAccessoryMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+10 -11
View File
@@ -8,9 +8,9 @@ use App\Models\Setting;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Queue\SerializesModels;
class CheckinAssetMail extends BaseMailable
@@ -53,7 +53,6 @@ class CheckinAssetMail extends BaseMailable
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return Content
*/
public function content(): Content
{
@@ -67,14 +66,14 @@ class CheckinAssetMail extends BaseMailable
return new Content(
markdown: 'mail.markdown.checkin-asset',
with: [
'item' => $this->item,
'status' => $this->item->assetstatus?->name,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
'fields' => $fields,
'expected_checkin' => $this->expected_checkin,
with: [
'item' => $this->item,
'status' => $this->item->assetstatus?->name,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
'fields' => $fields,
'expected_checkin' => $this->expected_checkin,
],
);
}
@@ -82,7 +81,7 @@ class CheckinAssetMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+7 -7
View File
@@ -2,12 +2,12 @@
namespace App\Mail;
use App\Models\Accessory;
use App\Models\Component;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -48,11 +48,11 @@ class CheckinComponentMail extends BaseMailable
{
return new Content(
markdown: 'mail.markdown.checkin-component',
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
]
);
}
@@ -60,7 +60,7 @@ class CheckinComponentMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+8 -7
View File
@@ -7,6 +7,7 @@ use App\Models\Setting;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -47,12 +48,12 @@ class CheckinLicenseMail extends BaseMailable
{
return new Content(
markdown: 'mail.markdown.checkin-license',
with: [
'license_seat' => $this->item,
'license' => $this->item->license,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
with: [
'license_seat' => $this->item,
'license' => $this->item->license,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
]
);
}
@@ -60,7 +61,7 @@ class CheckinLicenseMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+4 -1
View File
@@ -5,6 +5,7 @@ namespace App\Mail;
use App\Models\CheckoutAcceptance;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -14,7 +15,9 @@ class CheckoutAcceptanceResponseMail extends BaseMailable
use Queueable, SerializesModels;
public CheckoutAcceptance $acceptance;
public User $recipient;
public bool $wasAccepted;
/**
@@ -61,7 +64,7 @@ class CheckoutAcceptanceResponseMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+19 -19
View File
@@ -9,6 +9,7 @@ use App\Models\Setting;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -59,27 +60,25 @@ class CheckoutAccessoryMail extends BaseMailable
$accept_url = is_null($this->acceptance) ? null : route('account.accept.item', $this->acceptance);
$name = null;
if($this->target instanceof User){
if ($this->target instanceof User) {
$name = $this->target->display_name;
}
else if($this->target instanceof Asset){
$name = $this->target->assignedto?->display_name;
}
else if($this->target instanceof Location){
$name = $this->target->manager->name;
} elseif ($this->target instanceof Asset) {
$name = $this->target->assignedto?->display_name;
} elseif ($this->target instanceof Location) {
$name = $this->target->manager->name;
}
return new Content(
markdown: 'mail.markdown.checkout-accessory',
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $name,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
'checkout_qty' => $this->checkout_qty,
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $name,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
'checkout_qty' => $this->checkout_qty,
'introduction_line' => $this->introductionLine(),
],
);
@@ -95,17 +94,18 @@ class CheckoutAccessoryMail extends BaseMailable
return trans_choice('mail.new_item_checked_with_acceptance', $this->checkout_qty);
}
if ($this->firstTimeSending && !$this->requiresAcceptance()) {
if ($this->firstTimeSending && ! $this->requiresAcceptance()) {
return trans_choice('mail.new_item_checked', $this->checkout_qty);
}
if (!$this->firstTimeSending && $this->requiresAcceptance()) {
if (! $this->firstTimeSending && $this->requiresAcceptance()) {
return trans('mail.recent_item_checked');
}
// we shouldn't get here but let's send a default message just in case
return trans('new_item_checked');
}
private function requiresAcceptance(): int|bool
{
return method_exists($this->item, 'requireAcceptance') ? $this->item->requireAcceptance() : 0;
@@ -114,7 +114,7 @@ class CheckoutAccessoryMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+19 -21
View File
@@ -22,6 +22,7 @@ class CheckoutAssetMail extends BaseMailable
/**
* Create a new message instance.
*
* @throws \Exception
*/
public function __construct(Asset $asset, $checkedOutTo, ?User $checkedOutBy, $acceptance, $note, bool $firstTimeSending = true)
@@ -67,7 +68,6 @@ class CheckoutAssetMail extends BaseMailable
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return Content
*/
public function content(): Content
{
@@ -77,14 +77,12 @@ class CheckoutAssetMail extends BaseMailable
$fields = [];
$name = null;
if($this->target instanceof User){
if ($this->target instanceof User) {
$name = $this->target->display_name;
}
else if($this->target instanceof Asset){
$name = $this->target->assignedto?->display_name;
}
else if($this->target instanceof Location){
$name = $this->target->manager?->name;
} elseif ($this->target instanceof Asset) {
$name = $this->target->assignedto?->display_name;
} elseif ($this->target instanceof Location) {
$name = $this->target->manager?->name;
}
// Check if the item has custom fields associated with it
@@ -96,18 +94,18 @@ class CheckoutAssetMail extends BaseMailable
return new Content(
markdown: 'mail.markdown.checkout-asset',
with: [
'item' => $this->item,
'admin' => $this->admin,
'status' => $this->item->assetstatus?->name,
'note' => $this->note,
'target' => $name,
'fields' => $fields,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
with: [
'item' => $this->item,
'admin' => $this->admin,
'status' => $this->item->assetstatus?->name,
'note' => $this->note,
'target' => $name,
'fields' => $fields,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
'last_checkout' => $this->last_checkout,
'expected_checkin' => $this->expected_checkin,
'expected_checkin' => $this->expected_checkin,
'introduction_line' => $this->introductionLine(),
],
);
@@ -142,11 +140,11 @@ class CheckoutAssetMail extends BaseMailable
return trans_choice('mail.new_item_checked_with_acceptance', 1);
}
if ($this->firstTimeSending && !$this->requiresAcceptance()) {
if ($this->firstTimeSending && ! $this->requiresAcceptance()) {
return trans_choice('mail.new_item_checked', 1);
}
if (!$this->firstTimeSending && $this->requiresAcceptance()) {
if (! $this->firstTimeSending && $this->requiresAcceptance()) {
return trans('mail.recent_item_checked');
}
+11 -10
View File
@@ -7,6 +7,7 @@ use App\Models\Setting;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -56,15 +57,15 @@ class CheckoutComponentMail extends BaseMailable
return new Content(
markdown: 'mail.markdown.checkout-component',
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
'qty' => $this->qty,
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
'qty' => $this->qty,
]
);
}
@@ -72,7 +73,7 @@ class CheckoutComponentMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+13 -12
View File
@@ -7,6 +7,7 @@ use App\Models\Setting;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -59,15 +60,15 @@ class CheckoutConsumableMail extends BaseMailable
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,
'qty' => $this->qty,
with: [
'item' => $this->item,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
'qty' => $this->qty,
'introduction_line' => $this->introductionLine(),
]
);
@@ -76,7 +77,7 @@ class CheckoutConsumableMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
@@ -98,11 +99,11 @@ class CheckoutConsumableMail extends BaseMailable
return trans_choice('mail.new_item_checked_with_acceptance', $this->qty);
}
if ($this->firstTimeSending && !$this->requiresAcceptance()) {
if ($this->firstTimeSending && ! $this->requiresAcceptance()) {
return trans_choice('mail.new_item_checked', $this->qty);
}
if (!$this->firstTimeSending && $this->requiresAcceptance()) {
if (! $this->firstTimeSending && $this->requiresAcceptance()) {
return trans('mail.recent_item_checked');
}
+16 -15
View File
@@ -8,6 +8,7 @@ use App\Models\Setting;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -31,10 +32,9 @@ class CheckoutLicenseMail extends BaseMailable
$this->target = $checkedOutTo;
$this->firstTimeSending = $firstTimeSending;
if($this->target instanceof User){
if ($this->target instanceof User) {
$this->target = $this->target->display_name;
}
elseif($this->target instanceof Asset){
} elseif ($this->target instanceof Asset) {
$this->target = $this->target->display_name;
}
}
@@ -61,17 +61,18 @@ class CheckoutLicenseMail extends BaseMailable
$req_accept = method_exists($this->item, 'requireAcceptance') ? $this->item->requireAcceptance() : 0;
$accept_url = is_null($this->acceptance) ? null : route('account.accept.item', $this->acceptance);
return new Content(
markdown: 'mail.markdown.checkout-license',
with: [
'license_seat' => $this->item,
'license' => $this->item->license,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
with: [
'license_seat' => $this->item,
'license' => $this->item->license,
'admin' => $this->admin,
'note' => $this->note,
'target' => $this->target,
'eula' => $eula,
'req_accept' => $req_accept,
'accept_url' => $accept_url,
'introduction_line' => $this->introductionLine(),
]
);
@@ -80,7 +81,7 @@ class CheckoutLicenseMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
@@ -102,11 +103,11 @@ class CheckoutLicenseMail extends BaseMailable
return trans_choice('mail.new_item_checked_with_acceptance', 1);
}
if ($this->firstTimeSending && !$this->requiresAcceptance()) {
if ($this->firstTimeSending && ! $this->requiresAcceptance()) {
return trans_choice('mail.new_item_checked', 1);
}
if (!$this->firstTimeSending && $this->requiresAcceptance()) {
if (! $this->firstTimeSending && $this->requiresAcceptance()) {
return trans('mail.recent_item_checked');
}
+4 -3
View File
@@ -4,6 +4,7 @@ namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -42,8 +43,8 @@ class ExpiringAssetsMail extends BaseMailable
return new Content(
markdown: 'notifications.markdown.report-expiring-assets',
with: [
'assets' => $this->assets,
'threshold' => $this->threshold,
'assets' => $this->assets,
'threshold' => $this->threshold,
]
);
}
@@ -51,7 +52,7 @@ class ExpiringAssetsMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+4 -3
View File
@@ -4,6 +4,7 @@ namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -42,8 +43,8 @@ class ExpiringLicenseMail extends BaseMailable
return new Content(
markdown: 'notifications.markdown.report-expiring-licenses',
with: [
'licenses' => $this->licenses,
'threshold' => $this->threshold,
'licenses' => $this->licenses,
'threshold' => $this->threshold,
]
);
}
@@ -51,7 +52,7 @@ class ExpiringLicenseMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+6 -6
View File
@@ -4,6 +4,7 @@ namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -41,14 +42,13 @@ class SendUpcomingAuditMail extends BaseMailable
public function content(): Content
{
return new Content(
markdown: 'notifications.markdown.upcoming-audits',
with: [
'assets' => $this->assets,
'threshold' => $this->threshold,
'total' => $this->total,
with: [
'assets' => $this->assets,
'threshold' => $this->threshold,
'total' => $this->total,
],
);
}
@@ -56,7 +56,7 @@ class SendUpcomingAuditMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{
+6 -5
View File
@@ -4,6 +4,7 @@ namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -46,10 +47,10 @@ class UnacceptedAssetReminderMail extends BaseMailable
return new Content(
markdown: 'notifications.markdown.asset-reminder',
with: [
'count' => $this->count,
'assigned_to' => $this->target?->present()->fullName,
'link' => route('account.accept'),
'accept_url' => $accept_url,
'count' => $this->count,
'assigned_to' => $this->target?->present()->fullName,
'link' => route('account.accept'),
'accept_url' => $accept_url,
]
);
}
@@ -57,7 +58,7 @@ class UnacceptedAssetReminderMail extends BaseMailable
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
* @return array<int, Attachment>
*/
public function attachments(): array
{