Laravel 5.3 的 Lob.com 通知频道

1.2.5 2024-03-09 18:00 UTC

This package is auto-updated.

Last update: 2024-09-09 19:02:30 UTC


README

从 laravel-notification-channels 分支出来,为新的 Lob API 添加回调和合并变量

此包使您可以使用 Laravel 5.5、6.x 和 7.x 通过 Lob.com 发送通知变得简单

内容

安装

您可以通过 composer 安装此包

composer require laravel-notification-channels/lob

您必须安装服务提供者

// config/app.php
'providers' => [
    ...
    NotificationChannels\Lob\LobServiceProvider::class,
],

设置 lob

// config/services.php
...
'lob' => [
    'api_key' => env('LOB_API_KEY'),
],
...

使用

现在您可以在通知的 via() 方法中使用此频道

use NotificationChannels\Lob\LobChannel;
use NotificationChannels\Lob\LobPostcard;
use NotificationChannels\Lob\LobAddress;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [LobChannel::class];
    }

    public function toLobPostcard($notifiable)
    {
        return LobPostcard::create()
            ->toAddress(
                LobAddress::create('300 BOYLSTON AVE E')
                    ->name('John Smith')
                    ->city('SEATTLE')
                    ->state('WA')
                    ->zip('98002');
            )
            ->front('https://path.to/my/image/postcardfront.png')
            ->message('Wishing you a wonderful weekend!');
    }
}

可用的明信片方法

  • fromAddress() 发件人地址。
  • toAddress() 收件人地址。
  • country() 设置国家。默认为 US
  • city() 如果国家为 US 则必需。
  • state() 如果国家为 US 则必需。
  • zip() 如果国家为 US 则必需。
  • front() 作为明信片封面的 4.25"x6.25" 或 6.25"x11.25" 的图片。
  • message() 卡片背面的消息。

变更日志

请参阅 变更日志 了解最近更改的信息。

测试

$ composer test

安全

如果您发现任何安全相关的问题,请通过电子邮件 themsaid@gmail.com 而不是使用问题跟踪器。

贡献

请参阅 贡献指南 了解详细信息。

鸣谢

许可

MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。