1 | <?php |
||
12 | class Notification extends NotificationBase |
||
13 | { |
||
14 | protected $event; |
||
15 | |||
16 | public function via($notifiable) |
||
|
|||
17 | { |
||
18 | return config('laravel-failed-job-monitor.channels'); |
||
19 | } |
||
20 | |||
21 | public function setEvent(JobFailed $event) |
||
22 | { |
||
23 | $this->event = $event; |
||
24 | |||
25 | return $this; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Get the mail representation of the notification. |
||
30 | * |
||
31 | * @param mixed $notifiable |
||
32 | * @return \Illuminate\Notifications\Messages\MailMessage |
||
33 | */ |
||
34 | public function toMail($notifiable) |
||
35 | { |
||
36 | return (new MailMessage) |
||
37 | ->subject(trans('laravel-failed-job-monitor::mail.subject')) |
||
38 | ->greeting(trans('laravel-failed-job-monitor::mail.greeting')) |
||
39 | ->line(trans('laravel-failed-job-monitor::mail.intro')) |
||
40 | ->line(trans('laravel-failed-job-monitor::mail.job_info', ['job' => $this->event->job->resolveName()])) |
||
41 | ->line(trans('laravel-failed-job-monitor::mail.attachment')) |
||
42 | ->attachData($this->buildException($this->event->exception), |
||
43 | 'failed_job_'.Carbon::now()->format('Y-m-d h:i:s').'.txt') |
||
44 | ->attachData($this->event->job->getRawBody(), |
||
45 | 'payload_'.Carbon::now()->format('Y-m-d h:i:s').'.txt'); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get the Slack representation of the notification. |
||
50 | * |
||
51 | * @param mixed $notifiable |
||
52 | * @return \Illuminate\Notifications\Messages\SlackMessage |
||
53 | */ |
||
54 | public function toSlack($notifiable) |
||
70 | |||
71 | protected function buildException(\Exception $exception) |
||
72 | { |
||
73 | $response = sprintf( |
||
86 | } |
||
87 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.