Home > Mobile >  send notification without using User model
send notification without using User model

Time:10-14

How can I send a notification without having to use the User model?

   public function SendSeguimiento(Request $request){


   $toUser = Clientes::find(2);


    

   Notification::send($toUser, new Seguimiento($toUser));
    // $pageName = 'widgets';
    return redirect()->route("clientes");
}

i try to send a notification to the email of the table Clientes in row 2

Database: enter image description here

Clientes Model:

 <?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',
    ];
}

Error:

enter image description here

help pls

CodePudding user response:

Add use Notifiable; in your Clientes model

class Clientes extends Model
{
    use Notifiable;
}

And then

$toUser->notify(new Seguimiento($toUser));

CodePudding user response:

Function routeNotificationFor() belongs to Notification trait. Simply, you need to use this trait in Clientes model.

...
use Illuminate\Notifications\Notifiable;

class Clientes extends Model
{
    use Notifiable;

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