lasthourcloud/app/Notifications/TestNotification.php

35 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Notifications;
2023-06-01 12:15:33 +02:00
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\DiscordChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
2023-06-01 12:15:33 +02:00
class TestNotification extends Notification implements ShouldQueue
{
use Queueable;
public function via(object $notifiable): array
{
2023-05-25 17:27:52 +01:00
$channels = [];
2023-06-01 13:24:20 +02:00
$notifiable->extra_attributes?->get('smtp_active') && $channels[] = EmailChannel::class;
$notifiable->extra_attributes?->get('discord_active') && $channels[] = DiscordChannel::class;
2023-05-25 17:27:52 +01:00
return $channels;
}
2023-06-12 12:00:01 +02:00
public function toMail(): MailMessage
{
return (new MailMessage)
2023-06-01 12:15:33 +02:00
->subject('Coolify Test Notification')
->line('Congratulations!')
->line('You have successfully received a test Email notification from Coolify. 🥳');
}
2023-06-12 12:00:01 +02:00
public function toDiscord(): string
{
2023-06-01 12:15:33 +02:00
return 'You have successfully received a test Discord notification from Coolify. 🥳 [Go to your dashboard](' . url('/') . ')';
}
}