在Laravel中,我正在从Oracle数据库向用户发送电子邮件通知。与Oracle的连接正常,但是尝试向用户发送电子邮件通知时出现以下错误:
调用未定义的方法stdClass :: routeNotificationFor() my_project /供应商 /laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php
我的通知类别如下:
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notifiable;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use App\User;
class Expired extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct( )
{
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
这是我发送通知的方式:
<?php
$end = Carbon::now()->addDays(15)->format('Y-m-d h:m:s');
$users = DB::select("select email from user_ where val_to >= '$end ' group by email ");
Notification :: send($ users,new Expired($ users));