@Jinrenjie 不是最优解,你这样相当于重写 email
了
我继续研究了下可以这么写:
在 app\Models\User
重写 sendEmailVerificationNotification
方法。
public function sendEmailVerificationNotification()
{
$this->notify(new \App\Notifications\VerifyEmailQueued);
}
创建 VerifyEmailQueued
并继承 VerifyEmail
:
php artisan make:notification VerifyEmailQueued
替换以下代码:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Auth\Notifications\VerifyEmail;
class VerifyEmailQueued extends VerifyEmail implements ShouldQueue
{
use Queueable;
//因为继承了 VerifyEmail,所以可以不用写下面的了,如果想自定义再重写方法即可
}
最后,如果是 homestead 环境,一定要在 homestead 里面测试,一定要在 homestead 里面测试,一定要在 homestead 里面测试。
我在外面死活监听不到,卡了一天。血的教训!!!我一直以为我的 redis 坏了
在 App\Http\Controllers\Auth\RegisterController
中重写如下方法:
protected function registered(Request $request, $user)
{
SendNotify::dispatch($user); // 发送邮件的异步任务
}
@Jinrenjie 不是最优解,你这样相当于重写 email
了
我继续研究了下可以这么写:
在 app\Models\User
重写 sendEmailVerificationNotification
方法。
public function sendEmailVerificationNotification()
{
$this->notify(new \App\Notifications\VerifyEmailQueued);
}
创建 VerifyEmailQueued
并继承 VerifyEmail
:
php artisan make:notification VerifyEmailQueued
替换以下代码:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Auth\Notifications\VerifyEmail;
class VerifyEmailQueued extends VerifyEmail implements ShouldQueue
{
use Queueable;
//因为继承了 VerifyEmail,所以可以不用写下面的了,如果想自定义再重写方法即可
}
最后,如果是 homestead 环境,一定要在 homestead 里面测试,一定要在 homestead 里面测试,一定要在 homestead 里面测试。
我在外面死活监听不到,卡了一天。血的教训!!!我一直以为我的 redis 坏了
推荐文章: