Skip to content

A free open source IT asset/license management system

Refactor Expected Checkin Notification into markdown and enable translation (#8236)

Dampfklonbe114176a256
diff --git a/app/Notifications/ExpectedCheckinNotification.php b/app/Notifications/ExpectedCheckinNotification.php
index e7262ae54e..dadd920cf0 100644
--- a/app/Notifications/ExpectedCheckinNotification.php
+++ b/app/Notifications/ExpectedCheckinNotification.php
@@ -2,7 +2,7 @@
namespace App\Notifications;
-use Carbon\Carbon;
+use App\Helpers\Helper;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -46,16 +46,18 @@ class ExpectedCheckinNotification extends Notification
*/
public function toMail()
{
- $formatted_due = Carbon::parse($this->params->expected_checkin)->format('D, M j, Y');
- return (new MailMessage)
- ->error()
- ->subject('Reminder: '.$this->params->present()->name().' checkin deadline approaching')
- ->line('Hi, '.$this->params->assignedto->first_name.' '.$this->params->assignedto->last_name)
- ->greeting('An asset checked out to you is due to be checked back in on '.$formatted_due.'.')
- ->line('Asset: '.$this->params->present()->name())
- ->line('Serial: '.$this->params->serial)
- ->line('Asset Tag: '.$this->params->asset_tag)
- ->action('View Your Assets', route('view-assets'));
+
+ $message = (new MailMessage)->markdown('notifications.markdown.expected-checkin',
+ [
+ 'date' => Helper::getFormattedDateObject($this->params->expected_checkin, 'date', false),
+ 'asset' => $this->params->present()->name(),
+ 'serial' => $this->params->serial,
+ 'asset_tag' => $this->params->asset_tag
+ ])
+ ->subject(trans('mail.Expected_Checkin_Notification', ['name' => $this->params->present()->name()]));
+
+ return $message;
+
}
}
diff --git a/resources/lang/en/mail.php b/resources/lang/en/mail.php
index 837d71fa61..23cc8e58b8 100644
--- a/resources/lang/en/mail.php
+++ b/resources/lang/en/mail.php
@@ -74,4 +74,7 @@ return array(
'Asset_Checkin_Notification' => 'Asset checked in',
'License_Checkin_Notification' => 'License checked in',
'Expected_Checkin_Report' => 'Expected asset checkin report'
+ 'Expected_Checkin_Notification' => 'Reminder: :name checkin deadline approaching',
+ 'Expected_Checkin_Date' => 'An asset checked out to you is due to be checked back in on :date',
+ 'your_assets' => 'View Your Assets'
);
diff --git a/resources/views/notifications/markdown/expected-checkin.blade.php b/resources/views/notifications/markdown/expected-checkin.blade.php
new file mode 100644
index 0000000000..182f88ec1e
--- /dev/null
+++ b/resources/views/notifications/markdown/expected-checkin.blade.php
@@ -0,0 +1,20 @@
+@component('mail::message')
+# {{ trans('mail.hello') }},
+
+{{ trans('mail.Expected_Checkin_Date', ['date' => $date]) }}
+
+@if ((isset($asset)) && ($asset!=''))
+{{ trans('mail.asset_name') }} {{ $asset }}
+@endif
+{{ trans('mail.asset_tag') }} {{ $asset_tag }}
+@if (isset($serial))
+{{ trans('mail.serial') }}: {{ $serial }}
+@endif
+
+**[{{ trans('mail.your_assets') }}]({{ route('view-assets') }})**
+
+{{ trans('mail.best_regards') }}
+
+{{ $snipeSettings->site_name }}
+
+@endcomponent