1

我正在尝试向我的应用程序上的成员发送电子邮件,但出现以下错误:

production.ERROR: 调用未定义方法 Illuminate\Database\Query\Builder::routeNotificationFor() {"exception":"[object] (BadMethodCallException(code: 0): Call to undefined method Illuminate\Database\Query\Builder:: routeNotificationFor() 在 /var/www/vhosts/.../laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2483)

我有具有Notifiable特征的成员模型,奇怪的问题是在我的本地机器上发送电子邮件......问题出在生产上......

有任何想法吗?

通知是通过以下方式触发的:

Notification::send($members_to_notify, new CommMessage($communication));

CommMessage课程是:

CommMessage.php

namespace App\Notifications\Communications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use App\Mail\Communications\Message as Mailable;

class CommMessage extends Notification implements ShouldQueue
{

    use Queueable;

    private $communication;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($communication)
    {
        $this->communication = $communication;

    }

    /**
     * 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 Mailable
     */
    public function toMail($notifiable)
    {
        return (new Mailable($this->communication))->to($notifiable->email);
    }
}

可邮寄Message类是:

消息.php

namespace App\Mail\Communications;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class Message extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * The appointment instance.
     *
     * @var Appointment
     */
    public $communication;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($communication)
    {
        $this->communication = $communication;

    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $this->replyTo($this->communication->school->email)
             ->markdown('emails.communications.message');

        $this->subject($this->communication->title);

        $this->withSwiftMessage(function ($message) {
            $message->getHeaders()
                    ->addTextHeader('X-Mailgun-Variables', json_encode([
                        'model_id' => $this->communication->id,
                        'model' => get_class($this->communication),
                        'email_type' => 11 //Communication message (EmailLogType)
                    ]));
        });

    }

}
4

1 回答 1

1

这个问题解决了。代码没有错误,我使用Supervisor来管理队列,我忘记在生产服务器上重新启动它。

于 2018-11-10T10:32:22.327 回答