首页 > 解决方案 > 从 Oracle 数据库向多个用户发送通知

问题描述

在 Laravel 中,我从 Oracle 数据库向用户发送电子邮件通知。与 Oracle 的连接正常,但尝试向用户发送电子邮件通知时出现以下错误:

调用 my_project/vendor /laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php 中未定义的方法 stdClass::routeNotificationFor()

我的通知类如下:

<?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));

标签: phplaraveloracle

解决方案


推荐阅读