PHP code example of karacweb / kchat-notification-channel

1. Go to this page and download the library: Download karacweb/kchat-notification-channel 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/ */

    

karacweb / kchat-notification-channel example snippets


return KChatMessage::create()
    ->to("123456789")
    ->content('The backup of your application succeeded')
    ->commentTo('987654321');

use Illuminate\Notifications\Notification;
use NotificationChannels\KChat\KChatChannel;
use NotificationChannels\KChat\KChatMessage;

class BackupSucceeded extends Notification
{
    public function via($notifiable)
    {
        return [KChatChannel::class];
    }

    public function toKChat($notifiable)
    {
        return KChatMessage::create()
            ->to("123456789")
            ->content('The backup of your application succeeded')
            ->commentTo('987654321'); // A post ID you wish to respond to
    }
}

public function routeNotificationForKChat(Notification $notification)
{
    return '123456789';
}

// app/Notifications/InterestingNotification.php
public function toKChat($notifiable)
{
    return KChatMessage::create()
        ->to("123456789")
        ->content(view('notificationTemplate', [
            'variable' => 'ABC',
        ]));
}

// resources/views/notificationTemplate.blade.php
** ✅ Bold title **

Lorem ipsum *dolor* sit amet, ~~consectetur~~ adipiscing elit...

Variable content {{ $variable }}