-
Notifications
You must be signed in to change notification settings - Fork 92
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
Owen Melbourne
committed
Aug 19, 2019
1 parent
fcbbd01
commit 6a17ccc
Showing
4 changed files
with
132 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use App\Website; | ||
use App\DnsScan; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Notification; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
|
||
class DnsHasChanged extends Notification | ||
{ | ||
use Queueable; | ||
/** | ||
* @var Website | ||
*/ | ||
private $website; | ||
|
||
/** | ||
* @var DnsScan | ||
*/ | ||
private $scan; | ||
|
||
/** | ||
* Create a new notification instance. | ||
* | ||
* @param Website $website | ||
* @param DnsScan $scan | ||
*/ | ||
public function __construct(Website $website, DnsScan $scan) | ||
{ | ||
$this->website = $website; | ||
$this->scan = $scan; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return ['database', 'mail']; | ||
} | ||
|
||
/** | ||
* Get the mail representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return \Illuminate\Notifications\Messages\MailMessage | ||
*/ | ||
public function toMail($notifiable) | ||
{ | ||
return (new MailMessage) | ||
->subject('π Change detected on: ' . $this->website->url) | ||
->markdown('mail.dns-changed', [ | ||
'website' => $this->website, | ||
'scan' => $this->scan, | ||
]); | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function toArray($notifiable) | ||
{ | ||
return [ | ||
'website_id' => $this->website->id, | ||
'url' => $this->website->dns_hostname, | ||
'changed_on' => $this->scan->created_at, | ||
'flat' => $this->scan->flat, | ||
'diff' => $this->scan->diff, | ||
]; | ||
} | ||
} |
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,18 @@ | ||
@component('mail::message') | ||
# π DNS change detected on: {{ $website->url }} | ||
|
||
The public DNS file has changed since the last scan - please check and make any necessary changes. | ||
|
||
Please see the diff below: | ||
|
||
<div style="padding: 20px; background: #f1f2fb;"> | ||
<pre style="margin:0;padding:0;"><code style="margin:0;padding:0;">{{ $scan->diff }}</code></pre> | ||
</div> | ||
|
||
@component('mail::button', ['url' => $website->show_link]) | ||
Open Monitor | ||
@endcomponent | ||
|
||
Thanks,<br> | ||
{{ config('app.name') }} | ||
@endcomponent |
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