2023-08-16 14:03:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications\Internal;
|
|
|
|
|
|
|
|
use App\Notifications\Channels\DiscordChannel;
|
2023-09-06 12:31:38 +00:00
|
|
|
use App\Notifications\Channels\TelegramChannel;
|
2023-08-16 14:03:30 +00:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
|
|
class GeneralNotification extends Notification implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Queueable;
|
|
|
|
|
2023-09-28 09:33:16 +00:00
|
|
|
public $tries = 1;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-06-19 06:59:46 +00:00
|
|
|
public function __construct(public string $message) {}
|
2023-08-16 14:03:30 +00:00
|
|
|
|
|
|
|
public function via(object $notifiable): array
|
|
|
|
{
|
2023-09-11 08:19:46 +00:00
|
|
|
$channels = [];
|
|
|
|
$isDiscordEnabled = data_get($notifiable, 'discord_enabled');
|
|
|
|
$isTelegramEnabled = data_get($notifiable, 'telegram_enabled');
|
|
|
|
|
|
|
|
if ($isDiscordEnabled) {
|
|
|
|
$channels[] = DiscordChannel::class;
|
|
|
|
}
|
|
|
|
if ($isTelegramEnabled) {
|
|
|
|
$channels[] = TelegramChannel::class;
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-09-11 08:19:46 +00:00
|
|
|
return $channels;
|
2023-08-16 14:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function toDiscord(): string
|
|
|
|
{
|
|
|
|
return $this->message;
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-09-06 12:31:38 +00:00
|
|
|
public function toTelegram(): array
|
|
|
|
{
|
|
|
|
return [
|
2024-06-10 20:43:34 +00:00
|
|
|
'message' => $this->message,
|
2023-09-06 12:31:38 +00:00
|
|
|
];
|
|
|
|
}
|
2023-08-16 14:03:30 +00:00
|
|
|
}
|