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

Co-authored-by: snipe <snipe@snipe.net>
This commit is contained in:
Dampfklon 2020-11-13 00:09:40 +01:00 committed by GitHub
parent 1f9b04405c
commit be114176a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 11 deletions

View file

@ -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;
}
}

View file

@ -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'
);

View file

@ -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