2023-05-19 17:01:56 +00:00
|
|
|
<?php
|
|
|
|
|
2023-07-28 08:55:26 +00:00
|
|
|
namespace App\Notifications;
|
2023-05-19 17:01:56 +00:00
|
|
|
|
|
|
|
use App\Notifications\Channels\DiscordChannel;
|
2023-08-08 09:51:36 +00:00
|
|
|
use App\Notifications\Channels\EmailChannel;
|
2023-05-19 17:01:56 +00:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
2023-07-28 08:55:26 +00:00
|
|
|
class Test extends Notification implements ShouldQueue
|
2023-05-19 17:01:56 +00:00
|
|
|
{
|
|
|
|
use Queueable;
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-07-28 08:55:26 +00:00
|
|
|
public function __construct(public string|null $emails = null)
|
2023-08-08 09:51:36 +00:00
|
|
|
{
|
|
|
|
}
|
2023-07-28 08:55:26 +00:00
|
|
|
|
2023-05-19 17:01:56 +00:00
|
|
|
public function via(object $notifiable): array
|
|
|
|
{
|
2023-05-25 16:27:52 +00:00
|
|
|
$channels = [];
|
2023-07-27 19:26:15 +00:00
|
|
|
$isEmailEnabled = data_get($notifiable, 'smtp_enabled');
|
|
|
|
$isDiscordEnabled = data_get($notifiable, 'discord_enabled');
|
2023-06-20 17:08:43 +00:00
|
|
|
|
2023-07-28 08:55:26 +00:00
|
|
|
if ($isDiscordEnabled && empty($this->emails)) {
|
2023-06-19 12:31:42 +00:00
|
|
|
$channels[] = DiscordChannel::class;
|
|
|
|
}
|
2023-06-20 17:08:43 +00:00
|
|
|
|
2023-07-28 08:55:26 +00:00
|
|
|
if ($isEmailEnabled && !empty($this->emails)) {
|
|
|
|
$channels[] = EmailChannel::class;
|
|
|
|
}
|
2023-05-25 16:27:52 +00:00
|
|
|
return $channels;
|
2023-05-19 17:01:56 +00:00
|
|
|
}
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-06-12 10:00:01 +00:00
|
|
|
public function toMail(): MailMessage
|
2023-05-19 17:01:56 +00:00
|
|
|
{
|
2023-06-19 12:31:42 +00:00
|
|
|
$mail = new MailMessage();
|
|
|
|
$mail->subject("Coolify Test Notification");
|
|
|
|
$mail->view('emails.test');
|
|
|
|
return $mail;
|
2023-05-19 17:01:56 +00:00
|
|
|
}
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-06-12 10:00:01 +00:00
|
|
|
public function toDiscord(): string
|
2023-05-19 17:01:56 +00:00
|
|
|
{
|
2023-06-21 08:48:43 +00:00
|
|
|
$message = 'This is a test Discord notification from Coolify.';
|
|
|
|
$message .= "\n\n";
|
|
|
|
$message .= '[Go to your dashboard](' . base_url() . ')';
|
|
|
|
return $message;
|
2023-05-19 17:01:56 +00:00
|
|
|
}
|
2023-08-08 09:51:36 +00:00
|
|
|
}
|