Skip to content

Repository files navigation

Notification Mail Channel

中文说明

Latest Version on PackagistTotal DownloadsGitHub license

Installation

composer require friendsofhyperf/notification-mail

Usage

Use Notifiable trait in Model

<?phpdeclare(strict_types=1);
namespaceApp\Model;
useFriendsOfHyperf\Notification\Traits\Notifiable;
useHyperf\DbConnection\Model\Model;
/** * @property int $id  * @property \Carbon\Carbon $created_at  * @property \Carbon\Carbon $updated_at  */class User extends Model
{
use Notifiable;
/** * The table associated with the model. */protected ?string$table = 'user';
// 通知邮箱publicfunctionrouteNotificationForMail(): string
{
return$this->mail;
}
}

Mail Notifications

php bin/hyperf.php gen:markdown-mail Test

output

namespaceApp\Mail;
useFriendsOfHyperf\Notification\Mail\Message\MailMessage;
useFriendsOfHyperf\Notification\Notification;
class Test extends Notification
{
/** * Create a new notification instance. */publicfunction__construct()
{
//
}
/** * Get the notification's delivery channels. * * @return array<int, string> */publicfunctionvia(object$notifiable): array
{
return ['mail'];
}
/** * Get the mail representation of the notification. */publicfunctiontoMail(object$notifiable): MailMessage
{
return (newMailMessage)->from('xxx@xxx.cn','Hyperf')->replyTo('xxx@qq.com','zds')->markdown('email');
}
/** * Get the array representation of the notification. * * @return array<string, mixed> */publicfunctiontoArray(object$notifiable): array
{
return [
//
];
}
}
// storage/view/email.blade.php
xxx

About

[READ-ONLY]The Mail Channel for friendsofhyperf/notification.

Resources

Security policy

Stars

0 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages