4

I have the following notification class:

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

class ConfirmEmailNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct()
    {
       //
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        $user = $notifiable;
        $url = url('/register/confirm/'. $user->confirmation_token);

        return (new MailMessage)
           ->subject('Confirm Email')
           ->markdown('emails.confirm', ['user' => $user, 'url' => $url]);

    }

    public function toArray($notifiable)
    {
        return [
            //
        ];
     }
}

In my controller I have the following:

$when = now()->addSeconds(30);
$user->notify((new ConfirmEmailNotification())->delay($when));

But nothing is getting added to the queue table - the emails is being fired instantly?

I configured the queue as follows.

In my env file:

QUEUE_DRIVER=database

In my config/queue.php I have renamed the table as follows:

'database' => [
        'driver' => 'database',
        'table' => 'queued_jobs',
        'queue' => 'default',
        'retry_after' => 90,
 ],

Run the following:

php artisan queue:table

php artisan migrate

php artisan queue:work

I've tried php artisan config:clear but no difference.

Any ideas chaps?

adam78
  • 9,668
  • 24
  • 96
  • 207

2 Answers2

4

Fixed by restarting php artisan serve

adam78
  • 9,668
  • 24
  • 96
  • 207
0

In my case, i forgot to update the QUEUE_CONNECTION property in .env file.

After updating the QUEUE_CONNECTION to database it worked as intended.

sh6210
  • 4,190
  • 1
  • 37
  • 27