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/ */

    

homedoctor-es / laravel-intercom example snippets


return [
    //other stuff
    'providers' => [
        //other stuff
        \HomedoctorEs\Laravel\Intercom\IntercomServiceProvider::class,
    ];
];

return [
    //other stuff
    'aliases' => [
        //other stuff
        'Intercom' => \HomedoctorEs\Laravel\Intercom\Facades\Intercom::class,
    ];
];

return [
    'is_channel_active' => env('INTERCOM_CHANNEL_ACTIVE', false),
    'api_token' => env('HOLDED_API_TOKEN'),
    'api_version' => env('HOLDED_API_VERSION', '2.3'),
    'admin_user_id' => env('INTERCOM_ADMIN_USER_ID')
];

$contacts = \HomedoctorEs\Laravel\Intercom\Facades\Intercom::users();

app(\HomedoctorEs\Laravel\Intercom\Intercom::class)->users();

class User
{
    use Notifiable;

    // ...

    public function routeNotificationForIntercom($notification): ?array
    {
        if (!$this->intercom_contact_id) {
            return null;
        }
        return [
            'type' => 'user',
            'id' => $this->intercom_contact_id
        ];
    }
}
bash
$ php composer.phar 

php artisan vendor:publish --provider="HomedoctorEs\Laravel\Intercom\IntercomServiceProvider"
 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
    }
}