PHP code example of digitalrisks / hubspot-notification-channel

1. Go to this page and download the library: Download digitalrisks/hubspot-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/ */

    

digitalrisks / hubspot-notification-channel example snippets


// config/app.php
'providers' => [
    ...
    DigitalRisks\Notifications\ServiceProvider::class,
],

// config/services.php
...
'hubspot' => [
    'app_access_token' => env('HUBSPOT_APP_ACCESS_TOKEN', null),
    'template_id' => env('TEMPLATE_NAME_ID', null)
],
...
 php


namespace App\Notifications;

use DigitalRisks\Notifications\Messages\HubspotMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

class SomethingHappened extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['hubspot'];
    }

    /**
     * Get the hubspot representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \DigitalRisks\Notifications\Messages\HubspotMessage
     */
    public function toMail($notifiable)
    {
        return (new HubspotMessage)
            ->templateId(config('services.hubspot.template_id'))
            ->contactProperties([])
            ->customProperties([]);
    }
}
 php


namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;
    
    /**
     * Route notifications for the Hubspot channel.
     *
     * @param  \Illuminate\Notifications\Notification  $notification
     * @return string
     */
    public function routeNotificationForHubspot($notification)
    {
        return $this->email;
    }
}