56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class BackupScheduleRunDispatchedNotification extends Notification
|
|
{
|
|
/**
|
|
* @param array{
|
|
* tenant_id:int,
|
|
* trigger:string,
|
|
* scheduled_for:string,
|
|
* backup_schedule_id?:int,
|
|
* backup_schedule_run_id?:int,
|
|
* schedule_ids?:array<int, int>,
|
|
* backup_schedule_run_ids?:array<int, int>
|
|
* } $metadata
|
|
*/
|
|
public function __construct(public array $metadata) {}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toDatabase(object $notifiable): array
|
|
{
|
|
$trigger = (string) ($this->metadata['trigger'] ?? 'run_now');
|
|
|
|
$title = match ($trigger) {
|
|
'retry' => 'Retry dispatched',
|
|
'bulk_retry' => 'Retries dispatched',
|
|
'bulk_run_now' => 'Runs dispatched',
|
|
default => 'Run dispatched',
|
|
};
|
|
|
|
$body = match ($trigger) {
|
|
'bulk_retry', 'bulk_run_now' => 'Backup runs have been queued.',
|
|
default => 'A backup run has been queued.',
|
|
};
|
|
|
|
return [
|
|
'title' => $title,
|
|
'body' => $body,
|
|
'metadata' => $this->metadata,
|
|
];
|
|
}
|
|
}
|