PHP code example of homedoctor-es / laravel-intercom
1. Go to this page and download the library: Download homedoctor-es/laravel-intercom 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/ */
class User
{
use Notifiable;
// ...
public function routeNotificationForIntercom($notification): ?array
{
if (!$this->intercom_contact_id) {
return null;
}
return [
'type' => 'user',
'id' => $this->intercom_contact_id
];
}
}
php
use HomedoctorEs\Laravel\Intercom\Notifications\Channel\IntercomChannel;
use HomedoctorEs\Laravel\Intercom\Notifications\Messages\IntercomMessage;
use Illuminate\Notifications\Notification;
class IntercomNotification extends Notification
{
public function via($notifiable)
{
return ["intercom"];
}
public function toIntercom($notifiable): IntercomMessage
{
return IntercomMessage::create("This is a test message")
->from(config('intercom.admin_user_id'))
->toUserId(xxxxx); //this param can be resolved later in routeNotificationForIntercom
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.