4

I'm having a problem where i'm trying to queue a message to send to the registered user, when i am running everything works, but the queue just wont work, can someone help me with this please? Here's the registration controller

 protected function create(array $data)
    {
      $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
            'type' => $data['type'],
        ]);
        $email = (string)$data['email'];
        $job = (new SendEmailJob($email))->delay(Carbon::now()->addSeconds(5));
        dispatch($job);

        return $user;
    }

I have checked if i can send email and it works i can send email but when i am pointing to a specific email rather to the data which came from the register form. Here's the SendEmailJob

 public function handle($user)
    {
        Mail::to($user)->send(new SendEmailMailable());
    }
Areg
  • 1,414
  • 1
  • 19
  • 39

1 Answers1

3

It sounds like you don't have a queue running. You can do this with

php artisan queue:work

It's also possible you will want a failed jobs table and artisan has a command for that:

php artisan queue:failed-table

php artisan migrate

If you want to delete all your failed jobs you can do this:

php artisan queue:flush

And I recommend reading up on all this on the laravel docs site: https://laravel.com/docs/5.7/queues

And I also want to share a good post on stackoverflow regarding queues.

techcyclist
  • 376
  • 1
  • 11