2024-11-12 21:37:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Notifications\Channels;
|
|
|
|
|
|
|
|
|
|
use App\Jobs\SendMessageToSlackJob;
|
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
|
|
|
|
class SlackChannel
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Send the given notification.
|
|
|
|
|
*/
|
2025-01-07 14:31:43 +00:00
|
|
|
public function send(SendsSlack $notifiable, Notification $notification): void
|
2024-11-12 21:37:55 +00:00
|
|
|
{
|
|
|
|
|
$message = $notification->toSlack();
|
2025-01-07 14:31:43 +00:00
|
|
|
$slackSettings = $notifiable->slackNotificationSettings;
|
2024-12-09 16:36:32 +00:00
|
|
|
|
|
|
|
|
if (! $slackSettings || ! $slackSettings->isEnabled() || ! $slackSettings->slack_webhook_url) {
|
2024-11-12 21:37:55 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2024-12-09 16:36:32 +00:00
|
|
|
|
|
|
|
|
SendMessageToSlackJob::dispatch($message, $slackSettings->slack_webhook_url);
|
2024-11-12 21:37:55 +00:00
|
|
|
}
|
2024-12-06 13:33:22 +00:00
|
|
|
}
|