请问自带的注册机制是怎么用 Redis 异步功能,不然邮箱发送太久了

RT

看了源码,好像没有快捷开启的方法,只能重写,重写的话一堆东西不能用。

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

@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 坏了

4年前 评论
讨论数量: 2

App\Http\Controllers\Auth\RegisterController 中重写如下方法:

protected function registered(Request $request, $user)
{
    SendNotify::dispatch($user); // 发送邮件的异步任务
}
4年前 评论

@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 坏了

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!