2017-04-13 99 views
2

我需要帮助来解决通知系统的问题。在Laravel 5.4通知中找不到类'Illuminate Mail Events MessageSent'

这里是我的通知类:

<?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 [ 
      // 
     ]; 
     } 
} 

而这正是我把它叫做:

//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>"); 

当应用程序运行时,它发出的通知,但随后抛出了以下致命错误信息

FatalErrorException在Mailer.php行470: 班“照亮\邮件\活动\ MessageSent”未找到

the error displayed

我会感谢所有帮助指出我要去的地方错在这里。

+0

尝试重新运行'作曲家update'和/或run'composer自卸autoload'请MessageSent中的最后一个版本中加入(5.4.18)4天前 – dparoli

回答

1

谢谢@dparoli的建议。

但是,我试过composer dumpautoloadcomposer update都无济于事。

其实,我所做的解决了这个问题非常接近你的建议。创建新的laravel项目后,我意识到它包含与MessageSending.php相同位置的丢失文件(MessageSent.php)。

所以,我只是将文件(MessageSent.php)复制到我自己的项目中,并且它工作。

谢谢你的努力,并指出我在正确的方向。

我真的希望这可以帮助别人

2

Illuminate\Mail\Events\MessageSent仅在laravel(5.4.18)的最后一个版本中加入,所以你可以继续这样说:

运行composer update只是在情况下,最后运行中出了错。

如果错误仍然存​​在恕我直言,这可能是一个权限问题,所以一般有两种情况:

1)运行composer update与尚未在供应商目录写权限的用户,所以你必须使用另一个用户(见案例2)

2)你运行composer update和你忘记chown的laravel目录到web服务器的用户/组,即:

chmod -R nginx:nginx /path/to/laraveldir 

Sobstitute nginx:nginx与您的网络服务器user:group

在这两种情况下,停止开始到Web服务器的服务也可以帮助。

相关问题