-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
103 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use anlutro\LaravelSettings\Facade as Setting; | ||
use App\Mail\StaffNoticeMail; | ||
use App\Models\Endorsement; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Notification; | ||
|
||
class FeedbackNotification extends Notification implements ShouldQueue | ||
{ | ||
use Queueable; | ||
|
||
private $feedback; | ||
|
||
/** | ||
* Create a new notification instance. | ||
* | ||
* @param Endorsement $endorsement | ||
*/ | ||
public function __construct($feedback) | ||
{ | ||
$this->feedback = $feedback; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return ['mail', 'database']; | ||
} | ||
|
||
/** | ||
* Get the mail representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return EndorsementMail | ||
*/ | ||
public function toMail($notifiable) | ||
{ | ||
|
||
if (! Setting::get('feedbackEnabled')) { | ||
return false; | ||
} | ||
|
||
$position = isset($this->feedback->referencePosition) ? $this->feedback->referencePosition->callsign : 'N/A'; | ||
$controller = isset($this->feedback->referenceUser) ? $this->feedback->referenceUser->name : 'N/A'; | ||
|
||
$textLines = [ | ||
'New feedback has been submitted by ' . $this->feedback->submitter->name . ' (' . $this->feedback->submitter->id . ').', | ||
'*You can reply to this email to respond directly.*', | ||
'- **Controller**: ' . $controller, | ||
'- **Position**: ' . $position, | ||
'### Feedback', | ||
$this->feedback->feedback, | ||
|
||
]; | ||
|
||
$feedbackForward = Setting::get('feedbackForwardEmail'); | ||
|
||
return (new StaffNoticeMail('Feedback submited', $textLines)) | ||
->to($feedbackForward) | ||
->replyTo($this->feedback->submitter->email, $this->feedback->submitter->name); | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function toArray($notifiable) | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters