PHP code example of roerjo / laravel-notifications-sendgrid-driver

1. Go to this page and download the library: Download roerjo/laravel-notifications-sendgrid-driver 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/ */

    

roerjo / laravel-notifications-sendgrid-driver example snippets


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

/**
 * Get the mail representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return \Roerjo\LaravelNotificationsSendGridDriver\Messages\SendGridMailMessage
 */
public function toSendGrid($notifiable)
{
    $accountId = $this->profile->account()->first()->id;
    $channel = config("channels.{$this->profile->channel}.title");

    return (new SendGridMailMessage)
        ->sendgrid([
            'asm' => [
                'group_id' => config('services.sendgrid.unsubscribe_groups.external')
            ],
        ])
        ->error()
        ->subject("We Need To Re-Authenticate Your {$channel} Profile")
        ->line("The token for your {$channel} profile is no longer valid.")
        ->action(
            "Authenticate {$channel}",
            url("accounts/{$accountId}/profiles")
        )
        ->line('Thank you for helping us help you!');
}

use \Roerjo\LaravelNotificationsSendGridDriver\Messages\SendGridMailMessage;

Notification::route('sendgrid', '[email protected]')
    ->notify(new ReportNotification);