承接 snoeren-development/laravel-discord-webhook-channel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

snoeren-development/laravel-discord-webhook-channel

最新稳定版本:v1.12.2

Composer 安装命令:

composer require snoeren-development/laravel-discord-webhook-channel

包简介

Send notifications to a Discord webhook.

README 文档

README

Latest version on Packagist Software License Build status Downloads

Installation

You can install the package using Composer:

composer require snoeren-development/laravel-discord-webhook-channel

Requirements

This package requires at least PHP 8.2 and Laravel 10.

Usage

In every notifiable model you wish to notify via Discord, you need to add the routeNotificationForDiscord method;

use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; class User extends Model { use Notifiable; /**  * Route the notification for Discord.  *  * @return string  */ public function routeNotificationForDiscord(): string { return $this->discord_webhook; } }

The webhook URL can be created and retrieved via the Discord channel server Webhooks settings. The notification needs the full URL which looks like

https://discordapp.com/api/webhooks/1234567890123456789/1Px6cK9-9346g0CbOYArYjr1jj6X9rvRcCpRi3s7HePN0POeCSvuF1Iagb-Wjiq78BnT 

You may now send notifications through Laravel to Discord webhooks using the via method.

use SnoerenDevelopment\DiscordWebhook\DiscordMessage; use SnoerenDevelopment\DiscordWebhook\DiscordWebhookChannel; class DiscordNotification extends Notification { /**  * Get the notification's delivery channels.  *  * @param mixed $notifiable The notifiable model.  * @return array  */ public function via($notifiable) { return [DiscordWebhookChannel::class]; } /**  * Get the Discord representation of the notification.  *  * @param mixed $notifiable The notifiable model.  * @return \SnoerenDevelopment\DiscordWebhook\DiscordMessage  */ public function toDiscord($notifiable): DiscordMessage { return DiscordMessage::create() ->username('My Laravel App') ->content('The message body.') ->avatar('https://domain.com/avatar.jpg') ->tts(false); } }

Testing

$ composer test

Credits

License

The MIT license. See LICENSE for more information.

统计信息

  • 总下载量: 44.41k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固