-
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
b4a6661
commit fcbbd01
Showing
11 changed files
with
201 additions
and
365 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use App\Website; | ||
use App\RobotScan; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Notification; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
|
||
class RobotsHasChanged extends Notification | ||
{ | ||
use Queueable; | ||
/** | ||
* @var Website | ||
*/ | ||
private $website; | ||
|
||
/** | ||
* @var RobotScan | ||
*/ | ||
private $scan; | ||
|
||
/** | ||
* Create a new notification instance. | ||
* | ||
* @param Website $website | ||
* @param RobotScan $scan | ||
*/ | ||
public function __construct(Website $website, RobotScan $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.robots-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->robots_url, | ||
'changed_on' => $this->scan->created_at, | ||
'txt' => $this->scan->txt, | ||
'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
Oops, something went wrong.