revolution / laravel-notification-chatwork
Chatwork notifications channel for Laravel. (v2)
Requires
- php: >=7.1.3
- guzzlehttp/guzzle: ^6.0
- illuminate/notifications: ^5.5
- illuminate/support: ^5.5
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/database: ^3.5
- orchestra/testbench: ^3.5
- phpunit/phpunit: ^7.5
README
終了
使わなくなってきたのでpackagistからは削除。 composer.jsonで直接repositoriesを指定すれば使えるけど使いたい人がいるならフォークして自分で管理したほうがいい。
オリジナルからの変更点
フォークして使ってたけど毎回 composer.json で repositories の設定が面倒になってきたので別パッケージとして登録。
- ChatWork API v2
- メッセージごとに token 設定。別アカウントでも投稿するため。
- PHP7.1以上
- namespace 変更
composer require revolution/laravel-notification-chatwork
use Revolution\NotificationChannels\Chatwork\ChatworkMessage; return (new ChatworkMessage())->token('token') ->message('message');
This package makes it easy to send Chatwork messages using Chatwork API with Laravel 5.3.
Contents
Installation
You can install the package via composer:
composer require e2kaneko/laravel-chatwork-notifications
You must install the service provider:
// config/app.php 'providers' => [ ... NotificationChannels\Chatwork\ChatworkServiceProvider::class, ],
Configuration
Configure your credentials:
// config/services.php ... 'chatwork' => [ 'api_token' => env('CHATWORK_API_TOKEN'), ], ...
Usage
You can now use the channel in your via()
method inside the Notification class.
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use NotificationChannels\Chatwork\ChatworkMessage; use NotificationChannels\Chatwork\ChatworkChannel; class ChatworkPosted extends Notification { use Queueable; public function __construct() { } public function via($notifiable) { return [ChatworkChannel::class]; } public function toChatwork($notifiable) { return (new ChatworkMessage()) ->message('message'); } }
or
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use NotificationChannels\Chatwork\ChatworkInformation; use NotificationChannels\Chatwork\ChatworkChannel; class ChatworkPosted extends Notification { use Queueable; public function __construct() { } public function via($notifiable) { return [ChatworkChannel::class]; } public function toChatwork($notifiable) { return (new ChatworkInformation()) ->informationTitle('InformationTitle') ->informationMessage('InformationMessage'); } }
Routing a message
You can either send the notification by providing with the room_id of the recipient to the roomId($roomId) method like shown in the above example or add a routeNotificationForChatwork() method in your notifiable model:
... /** * Route notifications for the Chatwork channel. * * @return int */ public function routeNotificationForChatwork() { return '99999999'; // Chatwork Room ID } ...
Available Message methods
Message(ChatworkMessage)
roomId('roomId')
: (integer|string) Chatwork Room ID.to('accountId')
: (integer|string) .message('message')
: (string) Chat message.
Information(ChatworkInformation)
roomId('roomId')
: (integer|string) Chatwork Room ID.informationTitle('title')
: (string) Information Box Title.informationMessage('message')
: (string) Information Box Message.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email kaneko@e2info.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.