lasthourcloud/app/Notifications/Internal/GeneralNotification.php

46 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Notifications\Internal;
use App\Notifications\Channels\DiscordChannel;
2023-09-06 12:31:38 +00:00
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
class GeneralNotification extends Notification implements ShouldQueue
{
use Queueable;
2023-09-08 14:53:19 +00:00
public $tries = 5;
public function __construct(public string $message)
{
}
public function via(object $notifiable): array
{
$channels = [];
$isDiscordEnabled = data_get($notifiable, 'discord_enabled');
$isTelegramEnabled = data_get($notifiable, 'telegram_enabled');
if ($isDiscordEnabled) {
$channels[] = DiscordChannel::class;
}
if ($isTelegramEnabled) {
$channels[] = TelegramChannel::class;
}
return $channels;
}
public function toDiscord(): string
{
return $this->message;
}
2023-09-06 12:31:38 +00:00
public function toTelegram(): array
{
return [
"message" => $this->message,
];
}
}