From 4e0c8e218da5ee6568cde946d7bade49b9759c9b Mon Sep 17 00:00:00 2001 From: fordster78 Date: Sat, 3 Mar 2018 02:01:20 +0000 Subject: [PATCH] New Test Notification (#5137) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created Test Notification. Updated Vendor Mail message.blade files. Updated api settings controller to use Notification Façade. --- .../Controllers/Api/SettingsController.php | 7 ++- app/Models/Setting.php | 7 +++ app/Notifications/MailTest.php | 61 +++++++++++++++++++ resources/views/notifications/Test.blade.php | 7 +++ .../views/vendor/mail/html/layout.blade.php | 4 ++ .../views/vendor/mail/html/message.blade.php | 24 +++++++- .../vendor/mail/markdown/message.blade.php | 24 +++++++- 7 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 app/Notifications/MailTest.php create mode 100644 resources/views/notifications/Test.blade.php diff --git a/app/Http/Controllers/Api/SettingsController.php b/app/Http/Controllers/Api/SettingsController.php index 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.php index 7c824b9e62..71dfbbaae3 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -180,6 +180,13 @@ class Setting extends Model return $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.php new file mode 100644 index 0000000000..421cf7f988 --- /dev/null +++ b/app/Notifications/MailTest.php @@ -0,0 +1,61 @@ +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.php new file mode 100644 index 0000000000..a651f2f3f1 --- /dev/null +++ b/resources/views/notifications/Test.blade.php @@ -0,0 +1,7 @@ +@component('mail::message') + +{{ trans('mail.test_mail_text') }} + +Thanks,
+{{ $snipeSettings->site_name }} +@endcomponent diff --git a/resources/views/vendor/mail/html/layout.blade.php b/resources/views/vendor/mail/html/layout.blade.php index 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; + } diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.php index 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!='') + + @endif + {{ $snipeSettings->site_name }} + + @elseif ($snipeSettings->brand == '2') + @if ($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 diff --git a/resources/views/vendor/mail/markdown/message.blade.php b/resources/views/vendor/mail/markdown/message.blade.php index 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!='') + + @endif + {{ $snipeSettings->site_name }} + + @elseif ($snipeSettings->brand == '2') + @if ($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