<?php

namespace App\Notifications\Channels;

use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Http;

class SlackWebhookChannel
{
    public function send($notifiable, Notification $notification): void
    {
        $url = $notifiable->routeNotificationFor('slack', $notification);

        if (!$url) {
            return;
        }

        Http::post($url, [
            'text' => $notification->getMessage()
        ])->throw();

    }
}