laravel - 不使用用户模型发送通知
问题描述
如何在不使用User
模型的情况下发送通知?
public function SendSeguimiento(Request $request){
$toUser = Clientes::find(2);
Notification::send($toUser, new Seguimiento($toUser));
// $pageName = 'widgets';
return redirect()->route("clientes");
}
Clientes
我尝试向第 2 行表格的电子邮件发送通知
客户型号:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Clientes extends Model
{
protected $table= 'clientes';
//
protected $fillable = [
'id', 'codigo', 'cliente', 'email', 'created_at', 'updated_at',
];
}
错误:
请帮忙
解决方案
功能routeNotificationFor()
属于Notification
特质。简单地说,你需要在Clientes
模型中使用这个特性。
...
use Illuminate\Notifications\Notifiable;
class Clientes extends Model
{
use Notifiable;
protected $table= 'clientes';
...
}
推荐阅读
- javascript - jQuery用动态元素替换两个静态元素
- loops - 使用海龟图形定义函数的while循环
- python - 使用 python 创建蜂鸣器系统
- haskell - Haskell 自动补全以及 Emacs 中的一般信息和文档
- node.js - 为什么 app.engine 不默认 layout.hbs 作为默认值
- c# - 从两个列表返回不同项目列表的动态 LINQ 方法
- c++ - 无法在 box2d 碰撞回调中获取类数据
- database - PostgreSQL 查询将列更改为大写
- javascript - 头部的 Java 脚本函数导致正文中未定义 ReferenceError
- javascript - 如何避免浏览器中的闪烁问题?