roerjo/laravel-notifications-sendgrid-driver 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

roerjo/laravel-notifications-sendgrid-driver

最新稳定版本:v1.3.0

Composer 安装命令:

composer require roerjo/laravel-notifications-sendgrid-driver

包简介

This library adds a 'sendgrid' notification driver to Laravel.

README 文档

README

A Notification Driver with support for Sendgrid Web API.

Requirements

This package depends upon https://github.com/s-ichikawa/laravel-sendgrid-driver. Ensure that you have that package installed before using this package.

Install (Laravel)

composer require roerjo/laravel-notifications-sendgrid-driver

OR

Add the package to your composer.json and run composer update.

"require": {
    "roerjo/laravel-notifications-sendgrid-driver": "^1"
},

Usage

This package extends the functionality of the MailMessage class. It allows the addition of SendGrid API parameters in the same way that https://github.com/s-ichikawa/laravel-sendgrid-driver allows them to be added to the Mailable classes.

The sendgrid driver will need be utilized in the @via method of the Notification class:

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

Then, a toSendGrid method call can be used to generate the SendGridMailMessage:

/**
 * 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!');
}

Be sure to import SendGridMailMessage if not using the fully qualified namespace in toSendGrid:

use \Roerjo\LaravelNotificationsSendGridDriver\Messages\SendGridMailMessage;

Anonymous Notifications

Notification::route('sendgrid', 'test@test.com')
    ->notify(new ReportNotification);

统计信息

  • 总下载量: 18.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-08