2023-08-10 19:00:02 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications\Database;
|
|
|
|
|
|
|
|
use App\Models\ScheduledDatabaseBackup;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
|
|
class BackupSuccess extends Notification implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Queueable;
|
|
|
|
|
2023-09-18 13:19:27 +00:00
|
|
|
public $tries = 1;
|
2023-09-01 13:52:18 +00:00
|
|
|
public string $name;
|
|
|
|
public string $frequency;
|
2023-08-10 19:00:02 +00:00
|
|
|
|
|
|
|
public function __construct(ScheduledDatabaseBackup $backup, public $database)
|
|
|
|
{
|
2023-09-01 13:52:18 +00:00
|
|
|
$this->name = $database->name;
|
|
|
|
$this->frequency = $backup->frequency;
|
2023-08-10 19:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function via(object $notifiable): array
|
|
|
|
{
|
2023-09-06 12:31:38 +00:00
|
|
|
return setNotificationChannels($notifiable, 'database_backups');
|
2023-08-10 19:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function toMail(): MailMessage
|
|
|
|
{
|
|
|
|
$mail = new MailMessage();
|
2024-03-02 02:37:31 +00:00
|
|
|
$mail->subject("Last Hour Cloud: Backup successfully done for {$this->database->name}");
|
2023-09-01 13:52:18 +00:00
|
|
|
$mail->view('emails.backup-success', [
|
|
|
|
'name' => $this->name,
|
|
|
|
'frequency' => $this->frequency,
|
|
|
|
]);
|
2023-08-10 19:00:02 +00:00
|
|
|
return $mail;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function toDiscord(): string
|
|
|
|
{
|
2024-03-02 02:37:31 +00:00
|
|
|
return "Last Hour Cloud: Database backup for {$this->name} with frequency of {$this->frequency} was successful.";
|
2023-08-10 19:00:02 +00:00
|
|
|
}
|
2023-09-06 12:31:38 +00:00
|
|
|
public function toTelegram(): array
|
|
|
|
{
|
2024-03-02 02:37:31 +00:00
|
|
|
$message = "Last Hour Cloud: Database backup for {$this->name} with frequency of {$this->frequency} was successful.";
|
2023-09-06 12:31:38 +00:00
|
|
|
return [
|
|
|
|
"message" => $message,
|
|
|
|
];
|
|
|
|
}
|
2023-08-10 19:00:02 +00:00
|
|
|
}
|