PHP code example of friendsofhyperf / notification-mail
1. Go to this page and download the library: Download friendsofhyperf/notification-mail 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/ */
friendsofhyperf / notification-mail example snippets
declare(strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Model\Model;
use FriendsOfHyperf\Notification\Traits\Notifiable;
use Overtrue\EasySms\PhoneNumber;
/**
* @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';
// 通知手机号
public function routeNotificationForMail(): string|PhoneNumber
{
return $this->mail;
}
}
namespace App\Mail;
use FriendsOfHyperf\Notification\Mail\Message\MailMessage;
use FriendsOfHyperf\Notification\Notification;
class Test extends Notification
{
/**
* Create a new notification instance.
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)->from('[email protected]','Hyperf')->replyTo('[email protected]','zds')->markdown('email');
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}
// storage/view/email.blade.php
xxx
shell
php bin/hyperf.php gen:markdown-mail Test
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.