| Conditions | 4 |
| Paths | 6 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | public function send(Notification $notification): bool |
||
| 11 | { |
||
| 12 | try { |
||
| 13 | $channel = \Usamamuneerchaudhary\Notifier\Models\NotificationChannel::where('type', 'slack')->first(); |
||
| 14 | |||
| 15 | if (!$channel || !isset($channel->settings['webhook_url'])) { |
||
| 16 | return false; |
||
| 17 | } |
||
| 18 | |||
| 19 | $response = Http::post($channel->settings['webhook_url'], [ |
||
| 20 | 'text' => $notification->subject, |
||
| 21 | 'blocks' => [ |
||
| 22 | [ |
||
| 23 | 'type' => 'section', |
||
| 24 | 'text' => [ |
||
| 25 | 'type' => 'mrkdwn', |
||
| 26 | 'text' => $notification->content, |
||
| 27 | ], |
||
| 28 | ], |
||
| 29 | ], |
||
| 30 | ]); |
||
| 31 | |||
| 32 | return $response->successful(); |
||
| 33 | } catch (\Exception $e) { |
||
| 34 | \Log::error("Slack notification failed: " . $e->getMessage()); |
||
| 35 | return false; |
||
| 36 | } |
||
| 43 | } |