zoukankan      html  css  js  c++  java
  • laravel如何利用数据库的形式发送通知

    具体实现需要分几步:

    1.修改驱动为database;

    2.创建database的queue表

    3.创建任务sendMessage

    4.创建发送逻辑dispatch

    5.启动队列

    接下来我们进行实操:

    在项目中找到/config/queue.php

    我们修改这个驱动,为database,来到.env文件下进行修改

    接下来我们就执行第二步:创建database的queue表

    我们发现在migrations下多了一个文件

    然后执行 php artisan migrate 

    表创建成功

    接下来创建任务

    php artisan make:job SendMessage

    会发现在/app/下面多了一个文件 /jobs/SendMessage.php

     

     

    然后我们来到后台的noticeController下面

    创建发送通知

     

    最后一步就是启动队列

     

    php artisan queue:work

    为了防止窗口关闭,影响消息发送,我们将此消息挂起就可以了

    nohup php artisan queue:work >> /dev/null &

     

    ok!

     

  • 相关阅读:
    1、如何使用Azure Rest API创建虚拟机
    Ansible---2的Roles使用
    linux下的shell脚本
    生成器 yield和协程
    xshell
    markdown的使用
    加密
    Hbuilder打包app
    尾递归
    jupyter
  • 原文地址:https://www.cnblogs.com/gaosf/p/10042609.html
Copyright © 2011-2022 走看看