定制 fuyuan9/laravel-chatwork-notification-channel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fuyuan9/laravel-chatwork-notification-channel

Composer 安装命令:

composer require fuyuan9/laravel-chatwork-notification-channel

包简介

A Laravel notification channel for Chatwork using Chatwork API.

README 文档

README

A Laravel notification channel to send messages to the Japanese chat service Chatwork using the Chatwork API.

Installation

You can install the package via Composer:

composer require fuyuan9/laravel-chatwork-notification-channel

Requirements

  • PHP >= 8.0
  • Laravel >= 9.0
  • Chatwork API token (provided by Chatwork)

Configuration

  1. Add your Chatwork API token to the .env file:
CHATWORK_API_TOKEN=your-api-token-here
  1. The package will automatically register the ChatworkServiceProvider to inject the Chatwork API client.

Usage

To send a notification using this package, you need to:

  1. Define a toChatwork method in your Notification class.
  2. Specify the Chatwork room ID in your notifiable entity using routeNotificationFor('chatwork').

Example Notification

Here’s an example of how to define a notification:

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Fuyuan9\ChatworkMessage;

class TaskCompletedNotification extends Notification
{
    use Queueable;

    public function via($notifiable)
    {
        return ['chatwork'];
    }

    public function toChatwork($notifiable)
    {
        return ChatworkMessage::create("Task #1234 has been completed!");
    }
}

Example Notifiable Model

Here’s how you can define a notifiable model with the routeNotificationFor method:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class User extends Model
{
    use Notifiable;

    public function routeNotificationForChatwork()
    {
        return 1234; // Replace with the Chatwork room ID
    }
}

Sending the Notification

To send the notification, use the notify method:

$user = User::find(1);
$user->notify(new TaskCompletedNotification());

Testing

This package includes unit tests to verify its functionality.

Run the tests using PHPUnit:

vendor/bin/phpunit

Customization

If you want to customize how the Chatwork API client is created, you can modify the ChatworkServiceProvider or extend the package with your own logic.

Contributing

Contributions are welcome! Please submit a pull request or open an issue for any feature requests or bugs.

License

This package is open-source and licensed under the MIT License.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固