doujingxi3356 2017-04-13 12:40
浏览 94
已采纳

在Laravel 5.4通知中找不到类'Illuminate \ Mail \ Events \ MessageSent'

I need help to resolve an issue with the notification system.

Here is my notification class:

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class ApplicationReceived extends Notification
{
    use Queueable;


    private $testCode;
    private $recipientName;
    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($testCode='',$name='')
    {
        $this->testCode=$testCode;
        $this->recipientName=$name;
    }

    /**
     * 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)
                ->greeting("Dear ".$this->recipientName)
                ->subject('Your Application Received for The Entrepreneur')
                ->line("Your application to participate in The Entrepreneur project has been received by us")
                ->line("Follow the link below to take a test to complete your application")
                ->action('Take Test', url('/taketest/'.$this->testCode))
                ->line('Thank you for your interest in The Entrepreneur project!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
      }
}

And this is where I call it:

//Notify the candidate
$candidate->notify(new ApplicationReceived($candidate->testcode, $candidate->othernames));
return redirect('/signup')->with('msg', "<div class='alert alert-success'><strong>Your registration information was successfully submitted!</strong><br /> Please check your email for a link to take a test to complete your enrollment!!!</div>");

When the application runs, it sends the notification but then throws up the following fatal error message

FatalErrorException in Mailer.php line 470: Class 'Illuminate\Mail\Events\MessageSent' not found

the error displayed

I will appreciate any help to point out where I am going wrong here.

  • 写回答

2条回答 默认 最新

  • douwenpin0428 2017-04-15 13:47
    关注

    Thank you @dparoli for your suggestion.

    However, I tried both composer dumpautoload and composer update all to no avail.

    Actually, what I did that solved the problem is very close to what you suggested. After creating a new laravel project, I realized that it contains the missing file (MessageSent.php) in the same location as MessageSending.php.

    So, I just copied the file (MessageSent.php) to the same in my own project and it worked.

    Thank you for your efforts and pointing me in the right direction.

    I really hope this helps someone

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码