Skip to content

Commit

Permalink
Added own staff notice mailable
Browse files Browse the repository at this point in the history
  • Loading branch information
blt950 committed Jul 31, 2022
1 parent d1a297d commit 395f50e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
47 changes: 47 additions & 0 deletions app/Mail/StaffNoticeMail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use App\Models\User;

class StaffNoticeMail extends Mailable
{
use Queueable, SerializesModels;

private $mailSubject, $user, $textLines;

/**
* Create a new message instance.
*
* @param string $mailSubject
* @param Endorsement $endorsement
* @param array $textLines an array of markdown lines to add
* @param string $contactMail optional contact e-mail to put in footer
* @param string $actionUrl optinal action button url
* @param string $actionText optional action button text
* @param string $actionColor optional bootstrap button color override
* @return void
*/
public function __construct(string $mailSubject, User $user, array $textLines)
{
$this->mailSubject = $mailSubject;
$this->user = $user;
$this->textLines = $textLines;
}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject($this->mailSubject)->markdown('mail.staffnotice', [
'textLines' => $this->textLines,
]);
}
}
4 changes: 2 additions & 2 deletions app/Notifications/InactiveOnlineStaffNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Notifications;

use App\Mail\WarningMail;
use App\Mail\StaffNoticeMail;
use App\Models\Endorsement;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function toMail($notifiable)
'All admins and moderators in area in question has been notified.',
];

return (new WarningMail('Unauthorized network logon recorded', $this->user, $textLines))
return (new StaffNoticeMail('Unauthorized network logon recorded', $this->user, $textLines))
->to($this->sendTo->pluck('email'));
}

Expand Down
17 changes: 17 additions & 0 deletions resources/views/mail/staffnotice.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@component('mail::message')

{{-- Greeting --}}
# Hello,

{{-- Intro Lines --}}
@foreach ($textLines as $line)
{{ $line }}

@endforeach

{{-- Subcopy --}}
@slot('subcopy')
This is an automatically generated notice. If you think you received this by error, contact the staff.
@endslot

@endcomponent

0 comments on commit 395f50e

Please sign in to comment.