@@ 11-48 (lines=38) @@ | ||
8 | use Spatie\Backup\Events\BackupWasSuccessful as BackupWasSuccessfulEvent; |
|
9 | use Spatie\Backup\Notifications\BaseNotification; |
|
10 | ||
11 | class BackupWasSuccessful extends BaseNotification |
|
12 | { |
|
13 | /** @var \Spatie\Backup\Events\BackupWasSuccessful */ |
|
14 | protected $event; |
|
15 | ||
16 | public function toMail(): MailMessage |
|
17 | { |
|
18 | $mailMessage = (new MailMessage) |
|
19 | ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) |
|
20 | ->subject(trans('backup::notifications.backup_successful_subject', ['application_name' => $this->applicationName()])) |
|
21 | ->line(trans('backup::notifications.backup_successful_body', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()])); |
|
22 | ||
23 | $this->backupDestinationProperties()->each(function ($value, $name) use ($mailMessage) { |
|
24 | $mailMessage->line("{$name}: $value"); |
|
25 | }); |
|
26 | ||
27 | return $mailMessage; |
|
28 | } |
|
29 | ||
30 | public function toSlack(): SlackMessage |
|
31 | { |
|
32 | return (new SlackMessage) |
|
33 | ->success() |
|
34 | ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) |
|
35 | ->to(config('backup.notifications.slack.channel')) |
|
36 | ->content(trans('backup::notifications.backup_successful_subject_title')) |
|
37 | ->attachment(function (SlackAttachment $attachment) { |
|
38 | $attachment->fields($this->backupDestinationProperties()->toArray()); |
|
39 | }); |
|
40 | } |
|
41 | ||
42 | public function setEvent(BackupWasSuccessfulEvent $event) |
|
43 | { |
|
44 | $this->event = $event; |
|
45 | ||
46 | return $this; |
|
47 | } |
|
48 | } |
|
49 |
@@ 11-48 (lines=38) @@ | ||
8 | use Spatie\Backup\Events\CleanupWasSuccessful as CleanupWasSuccessfulEvent; |
|
9 | use Spatie\Backup\Notifications\BaseNotification; |
|
10 | ||
11 | class CleanupWasSuccessful extends BaseNotification |
|
12 | { |
|
13 | /** @var \Spatie\Backup\Events\CleanupWasSuccessful */ |
|
14 | protected $event; |
|
15 | ||
16 | public function toMail(): MailMessage |
|
17 | { |
|
18 | $mailMessage = (new MailMessage) |
|
19 | ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) |
|
20 | ->subject(trans('backup::notifications.cleanup_successful_subject', ['application_name' => $this->applicationName()])) |
|
21 | ->line(trans('backup::notifications.cleanup_successful_body', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()])); |
|
22 | ||
23 | $this->backupDestinationProperties()->each(function ($value, $name) use ($mailMessage) { |
|
24 | $mailMessage->line("{$name}: $value"); |
|
25 | }); |
|
26 | ||
27 | return $mailMessage; |
|
28 | } |
|
29 | ||
30 | public function toSlack(): SlackMessage |
|
31 | { |
|
32 | return (new SlackMessage) |
|
33 | ->success() |
|
34 | ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) |
|
35 | ->to(config('backup.notifications.slack.channel')) |
|
36 | ->content(trans('backup::notifications.cleanup_successful_subject_title')) |
|
37 | ->attachment(function (SlackAttachment $attachment) { |
|
38 | $attachment->fields($this->backupDestinationProperties()->toArray()); |
|
39 | }); |
|
40 | } |
|
41 | ||
42 | public function setEvent(CleanupWasSuccessfulEvent $event) |
|
43 | { |
|
44 | $this->event = $event; |
|
45 | ||
46 | return $this; |
|
47 | } |
|
48 | } |
|
49 |
@@ 11-48 (lines=38) @@ | ||
8 | use Spatie\Backup\Events\HealthyBackupWasFound as HealthyBackupWasFoundEvent; |
|
9 | use Spatie\Backup\Notifications\BaseNotification; |
|
10 | ||
11 | class HealthyBackupWasFound extends BaseNotification |
|
12 | { |
|
13 | /** @var \Spatie\Backup\Events\HealthyBackupWasFound */ |
|
14 | protected $event; |
|
15 | ||
16 | public function toMail(): MailMessage |
|
17 | { |
|
18 | $mailMessage = (new MailMessage) |
|
19 | ->from(config('backup.notifications.mail.from.address', config('mail.from.address')), config('backup.notifications.mail.from.name', config('mail.from.name'))) |
|
20 | ->subject(trans('backup::notifications.healthy_backup_found_subject', ['application_name' => $this->applicationName(), 'disk_name' => $this->diskName()])) |
|
21 | ->line(trans('backup::notifications.healthy_backup_found_body', ['application_name' => $this->applicationName()])); |
|
22 | ||
23 | $this->backupDestinationProperties()->each(function ($value, $name) use ($mailMessage) { |
|
24 | $mailMessage->line("{$name}: $value"); |
|
25 | }); |
|
26 | ||
27 | return $mailMessage; |
|
28 | } |
|
29 | ||
30 | public function toSlack(): SlackMessage |
|
31 | { |
|
32 | return (new SlackMessage) |
|
33 | ->success() |
|
34 | ->from(config('backup.notifications.slack.username'), config('backup.notifications.slack.icon')) |
|
35 | ->to(config('backup.notifications.slack.channel')) |
|
36 | ->content(trans('backup::notifications.healthy_backup_found_subject_title', ['application_name' => $this->applicationName()])) |
|
37 | ->attachment(function (SlackAttachment $attachment) { |
|
38 | $attachment->fields($this->backupDestinationProperties()->toArray()); |
|
39 | }); |
|
40 | } |
|
41 | ||
42 | public function setEvent(HealthyBackupWasFoundEvent $event) |
|
43 | { |
|
44 | $this->event = $event; |
|
45 | ||
46 | return $this; |
|
47 | } |
|
48 | } |
|
49 |