A free open source IT asset/license management system
New Test Notification (#5137)
fordster784e0c8e218da5
diff --git a/app/Http/Controllers/Api/SettingsController.php b/app/Http/Controllers/Api/SettingsController.phpindex 942c4a5fe4..0d44337e5d 100644--- a/app/Http/Controllers/Api/SettingsController.php+++ b/app/Http/Controllers/Api/SettingsController.php@@ -10,6 +10,7 @@ use App\Models\Setting;use Mail;use App\Notifications\SlackTest;use Notification;+use App\Notifications\MailTest;class SettingsController extends Controller{@@ -132,11 +133,13 @@ class SettingsController extends Controller{if (!config('app.lock_passwords')) {try {- Mail::send('emails.test', [], function ($m) {+ Notification::send(Setting::first(), new MailTest());++ /*Mail::send('emails.test', [], function ($m) {$m->to(config('mail.reply_to.address'), config('mail.reply_to.name'));$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));$m->subject(trans('mail.test_email'));- });+ });*/return response()->json(['message' => 'Mail sent to '.config('mail.reply_to.address')], 200);} catch (Exception $e) {return response()->json(['message' => $e->getMessage()], 500);diff --git a/app/Models/Setting.php b/app/Models/Setting.phpindex 7c824b9e62..71dfbbaae3 100755--- a/app/Models/Setting.php+++ b/app/Models/Setting.php@@ -180,6 +180,13 @@ class Setting extends Modelreturn $this->slack_endpoint;}+ public function routeNotificationForMail()+ {+ // At this point the endpoint is the same for everything.+ // In the future this may want to be adapted for individual notifications.+ return config('mail.reply_to.address');+ }+public static function passwordComplexityRulesSaving($action = 'update'){$security_rules = '';diff --git a/app/Notifications/MailTest.php b/app/Notifications/MailTest.phpnew file mode 100644index 0000000000..421cf7f988--- /dev/null+++ b/app/Notifications/MailTest.php@@ -0,0 +1,61 @@+<?php++namespace App\Notifications;++use App\Models\Settings;+use Illuminate\Bus\Queueable;+use Illuminate\Notifications\Notification;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Notifications\Messages\MailMessage;++class MailTest extends Notification+{+ use Queueable;++ /**+ * Create a new notification instance.+ *+ * @return void+ */+ public function __construct()+ {+ //+ }++ /**+ * Get the notification's delivery channels.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function via($notifiable)+ {+ return ['mail'];+ }++ /**+ * Get the mail representation of the notification.+ *+ * @param mixed $notifiable+ * @return \Illuminate\Notifications\Messages\MailMessage+ */+ public function toMail($notifiable)+ {+ return (new MailMessage)+ ->subject(trans('mail.test_email'))+ ->markdown('notifications.Test');+ }++ /**+ * Get the array representation of the notification.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function toArray($notifiable)+ {+ return [+ //+ ];+ }+}diff --git a/resources/views/notifications/Test.blade.php b/resources/views/notifications/Test.blade.phpnew file mode 100644index 0000000000..a651f2f3f1--- /dev/null+++ b/resources/views/notifications/Test.blade.php@@ -0,0 +1,7 @@+@component('mail::message')++{{ trans('mail.test_mail_text') }}++Thanks,<br>+{{ $snipeSettings->site_name }}+@endcomponentdiff --git a/resources/views/vendor/mail/html/layout.blade.php b/resources/views/vendor/mail/html/layout.blade.phpindex 991ae52a88..c7c629d4a4 100644--- a/resources/views/vendor/mail/html/layout.blade.php+++ b/resources/views/vendor/mail/html/layout.blade.php@@ -21,6 +21,10 @@width: 100% !important;}}+ .logo {+ width:50px;+ height:50px;+ }</style><table class="wrapper" width="100%" cellpadding="0" cellspacing="0">diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.phpindex 2ad23a66e2..fbbf0db699 100644--- a/resources/views/vendor/mail/html/message.blade.php+++ b/resources/views/vendor/mail/html/message.blade.php@@ -2,7 +2,23 @@{{-- Header --}}@slot('header')@component('mail::header', ['url' => config('app.url')])- {{ config('app.name') }}+ @if($snipeSettings::setupCompleted())+ @if ($snipeSettings->brand == '3')+ @if ($snipeSettings->logo!='')+ <img class="navbar-brand-img logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">+ @endif+ {{ $snipeSettings->site_name }}++ @elseif ($snipeSettings->brand == '2')+ @if ($snipeSettings->logo!='')+ <img class="navbar-brand-img logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">+ @endif+ @else+ {{ $snipeSettings->site_name }}+ @endif+ @else+ Snipe-it+ @endif@endcomponent@endslot@@ -21,7 +37,11 @@{{-- Footer --}}@slot('footer')@component('mail::footer')- © {{ date('Y') }} {{ config('app.name') }}. All rights reserved.+ @if($snipeSettings::setupCompleted())+ © {{ date('Y') }} {{ $snipeSettings->site_name }}. All rights reserved.+ @else+ © {{ date('Y') }} Snipe-it. All rights reserved.+ @endif@endcomponent@endslot@endcomponentdiff --git a/resources/views/vendor/mail/markdown/message.blade.php b/resources/views/vendor/mail/markdown/message.blade.phpindex b409c71cb6..fbbf0db699 100644--- a/resources/views/vendor/mail/markdown/message.blade.php+++ b/resources/views/vendor/mail/markdown/message.blade.php@@ -2,7 +2,23 @@{{-- Header --}}@slot('header')@component('mail::header', ['url' => config('app.url')])- {{ config('app.name') }}+ @if($snipeSettings::setupCompleted())+ @if ($snipeSettings->brand == '3')+ @if ($snipeSettings->logo!='')+ <img class="navbar-brand-img logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">+ @endif+ {{ $snipeSettings->site_name }}++ @elseif ($snipeSettings->brand == '2')+ @if ($snipeSettings->logo!='')+ <img class="navbar-brand-img logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">+ @endif+ @else+ {{ $snipeSettings->site_name }}+ @endif+ @else+ Snipe-it+ @endif@endcomponent@endslot@@ -21,7 +37,11 @@{{-- Footer --}}@slot('footer')@component('mail::footer')- © {{ date('Y') }} {{ config('app.name') }}. All rights reserved.+ @if($snipeSettings::setupCompleted())+ © {{ date('Y') }} {{ $snipeSettings->site_name }}. All rights reserved.+ @else+ © {{ date('Y') }} Snipe-it. All rights reserved.+ @endif@endcomponent@endslot@endcomponent