namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Vance\LaravelNotificationEasySms\Channels\EasySmsChannel;
use Vance\LaravelNotificationEasySms\Messages\EasySmsMessage;
class VerificationCode extends Notification
{
use Queueable;
public function via($notifiable)
{
return [EasySmsChannel::class];
}
public function toEasySms($notifiable)
{
return (new EasySmsMessage)
->setContent('您的验证码为: 6379')
->setTemplate('SMS_001')
->setData(['code' => 6379]);
}
}
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Overtrue\EasySms\PhoneNumber;
class User extends Authenticatable
{
use Notifiable;
public function routeNotificationForEasySms($notification)
{
return new PhoneNumber($this->number, $this->area_code);
}
}