New Test Notification (#5137)

Created Test Notification.
Updated Vendor Mail message.blade files.
Updated api settings controller to use Notification Façade.
This commit is contained in:
fordster78 2018-03-03 02:01:20 +00:00 committed by snipe
parent 4fe4c0c72a
commit 4e0c8e218d
7 changed files with 128 additions and 6 deletions

View file

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

View file

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

View file

@ -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 [
//
];
}
}

View file

@ -0,0 +1,7 @@
@component('mail::message')
{{ trans('mail.test_mail_text') }}
Thanks,<br>
{{ $snipeSettings->site_name }}
@endcomponent

View file

@ -21,6 +21,10 @@
width: 100% !important;
}
}
.logo {
width:50px;
height:50px;
}
</style>
<table class="wrapper" width="100%" cellpadding="0" cellspacing="0">

View file

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

View file

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