2017-04-13 92 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服務器的服務也可以幫助。

相關問題