Created
May 17, 2018 08:02
-
-
Save yusidabcs/2e31c2d2d459fb533964d87bc22044b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
namespace App\Notifications; | |
use Illuminate\Bus\Queueable; | |
use Illuminate\Notifications\Notification; | |
use Illuminate\Notifications\Messages\SlackMessage; | |
use Exception; | |
class ErrorNotification extends Notification | |
{ | |
use Queueable; | |
public $exception; | |
/** | |
* Create a new notification instance. | |
* | |
* @return void | |
*/ | |
public function __construct(Exception $exception) | |
{ | |
$this->exception = $exception; | |
} | |
/** | |
* Get the notification's delivery channels. | |
* | |
* @param mixed $notifiable | |
* @return array | |
*/ | |
public function via($notifiable) | |
{ | |
return ['slack']; | |
} | |
/** | |
* Get the mail representation of the notification. | |
* | |
* @param mixed $notifiable | |
* @return \Illuminate\Notifications\Messages\MailMessage | |
*/ | |
public function toSlack($notifiable) | |
{ | |
return (new SlackMessage) | |
->from('laravel', ':ghost:') | |
->to('#general') | |
->content('ERROR: '.$this->exception->getMessage() . '(' . $this->exception->getCode() . ') => ' . $this->exception->getFile() . ':' . $this->exception->getline() ); | |
} | |
/** | |
* Get the array representation of the notification. | |
* | |
* @param mixed $notifiable | |
* @return array | |
*/ | |
public function toArray($notifiable) | |
{ | |
return [ | |
// | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment