首页 > 解决方案 > 不使用用户模型发送通知

问题描述

如何在不使用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',
    ];
}

错误:

在此处输入图像描述

请帮忙

标签: laravellaravel-5laravel-8

解决方案


功能routeNotificationFor()属于Notification特质。简单地说,你需要在Clientes模型中使用这个特性。

...
use Illuminate\Notifications\Notifiable;

class Clientes extends Model
{
    use Notifiable;

    protected $table= 'clientes';
    ...
}

推荐阅读