PHP code example of e2kaneko / laravel-chatwork-notifications

1. Go to this page and download the library: Download e2kaneko/laravel-chatwork-notifications library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

e2kaneko / laravel-chatwork-notifications example snippets


// config/app.php
'providers' => [
    ...
    NotificationChannels\Chatwork\ChatworkServiceProvider::class,
],

// config/services.php
...
'chatwork' => [
    'api_token' => env('CHATWORK_API_TOKEN'),
],
...

...
/**
 * Route notifications for the Chatwork channel.
 *
 * @return int
 */
public function routeNotificationForChatwork()
{
    return '99999999'; // Chatwork Room ID
}
...
 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');
    }
}

 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');
    }
}