konstruktiv / laravel-sendgrid-notification-channel
我们的Laravel Sendgrid通知包
v1.0.3
2022-01-18 12:05 UTC
Requires
- php: ^7.4|^8.0
- illuminate/notifications: ^6|^7|^8|^9
- illuminate/support: ^6|^7|^8|^9
- sendgrid/sendgrid: ^7.11
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-29 05:50:04 UTC
README
Laravel Sendgrid通知通道
安装
要开始使用,您需要要求此包
composer require konstruktiv/laravel-sendgrid-notification-channel
Laravel将自动检测服务提供者。因此,无需手动注册。
使用方法
要使用此包,您的通知类应如下所示
<?php namespace App\Notifications; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { public function via($notifiable) { return [ 'sendgrid', // And any other channels you want can go here... ]; } /** * Get the SendGrid representation of the notification. * * @param mixed $notifiable * @return SendGridMessage */ public function toSendGrid(mixed $notifiable): SendGridMessage { return (new SendGridMessage('Your SendGrid template ID')) ->subject('Subject goes here') ->from('sendgrid@example.com','SendGrid') ->to( $notifiable->email, $notifiable->name ) ->payload([ 'key' => 'value' ]); } }