2016-11-24 6 views
0

アクティベーション通知をオーバーライドしましたが、電子メールを送信する際に問題があります。それはキューを使用していないときに動作しています。それ以外の場合はデータベースキューに残りますが、それを修正する方法はわかりません。 しかし、キューがデータベースキューを使用して電子メールを送信していることが分かっています。ラーベール変更アクティベーションの電子メールとキュー

だから、これは動作しません。

<?php 

namespace App\Notifications; 

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

class SendActivationEmail extends Notification implements ShouldQueue 
{ 
    use Queueable; 

    protected $token; 

    /** 
    * Create a new notification instance. 
    * 
    * SendActivationEmail constructor. 
    * @param $token 
    */ 
    public function __construct($token) 
    { 
     $this->token = $token; 
     $this->onQueue('social'); 
    } 

    /** 
    * 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) 
      ->subject('Activation email') 
      ->greeting('xxx - Hello!') 
      ->line('You need to activate your email before you can start using all of our services.') 
      ->action('Activate Email', route('authenticated.activate', ['token' => $this->token])) 
      ->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 

namespace App\Notifications; 

use Illuminate\Notifications\Messages\MailMessage; 
use Illuminate\Notifications\Notification; 

class SendActivationEmail extends Notification 
{ 

    protected $token; 

    /** 
    * Create a new notification instance. 
    * 
    * SendActivationEmail constructor. 
    * @param $token 
    */ 
    public function __construct($token) 
    { 
     $this->token = $token; 
    } 

    /** 
    * 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) 
      ->subject('Activation email') 
      ->greeting('xxx - Hello!') 
      ->line('You need to activate your email before you can start using all of our services.') 
      ->action('Activate Email', route('authenticated.activate', ['token' => $this->token])) 
      ->line('Thank you for using our application!'); 
    } 

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

このようなものでも動作します:

Mail::to($user->email) 
      ->queue(new Welcome($user)); 

と私のデータベースのキューにある:(数をアテンプの増加を続ける)

{"job":"Illuminate\\Queue\\[email protected]","data":{"commandName":"Illuminate\\Notifications\\SendQueuedNotifications","command":"O:48:\"Illuminate\\Notifications\\SendQueuedNotifications\":6:{s:14:\"\u0000*\u0000notifiables\";O:45:\"Illuminate\\Contracts\\Database\\ModelIdentifier\":2:{s:5:\"class\";s:15:\"App\\Models\\User\";s:2:\"id\";a:1:{i:0;i:12;}}s:15:\"\u0000*\u0000notification\";O:43:\"App\\Notifications\\SendActivationEmail\":5:{s:8:\"\u0000*\u0000token\";s:64:\"f594ec1d2c15bf5c51903b1b408100b6de449895a042ddbe701d014b46a2bd8c\";s:2:\"id\";s:36:\"20d8a21a-3a69-47cf-a37d-bc98f2a83600\";s:10:\"connection\";N;s:5:\"queue\";s:7:\"default\";s:5:\"delay\";N;}s:11:\"\u0000*\u0000channels\";a:1:{i:0;s:4:\"mail\";}s:10:\"connection\";N;s:5:\"queue\";s:7:\"default\";s:5:\"delay\";N;}"}} 

答えて

0

テーブル通知を作成するのを忘れていて、それが必要であることを知らなかった。

php artisan notifications:table 
php artisan migrate 

はただ、これらの2のコマンドラインを実行する必要があります

関連する問題