PHP code example of rocont / laravel-notification-channel-compass
1. Go to this page and download the library: Download rocont/laravel-notification-channel-compass 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/ */
rocont / laravel-notification-channel-compass example snippets
return [
'default' => env('COMPASS_DEFAULT_BOT', 'main'),
'bots' => [
'main' => [
'token' => env('COMPASS_BOT_TOKEN'),
],
],
'base_url' => rtrim(env('COMPASS_BASE_URL', 'https://userbot.getcompass.com/'), '/') . '/api/v3/',
'timeout' => 10,
];
class User extends Model
{
use Notifiable;
// Return user_id (int) to send as DM
public function routeNotificationForCompass(): ?int
{
return $this->compass_user_id;
}
}
class WelcomeNotification extends Notification
{
public function via($notifiable): array
{
return ['compass'];
}
public function toCompass($notifiable): array
{
return [
'type' => 'text',
'text' => "Welcome, {$notifiable->name}!",
];
}
}
Notification::route('compass', ['group_id' => $groupId])
->notify(new WelcomeNotification());
public function toCompass($notifiable): array
{
return [
'type' => 'file',
'file' => '/path/to/document.pdf',
'message_id' => $this->threadId,
];
}
public function toCompass($notifiable): array
{
return [
'bot' => 'marketing', // key from config('compass.bots')
'type' => 'text',
'text' => 'Hello from marketing bot!',
];
}
bash
php artisan vendor:publish --provider="Rocont\CompassChannel\CompassServiceProvider" --tag=config