UPDATE: I needed to do it this way:
$user -> notify((new App\Notifications\FriendRequestCreated(13)) -> onQueue("email"));
BUT,
How can I specify a different queue for each of the "to" methods e.g. mail, array etc.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How do I specify which queue I want a Laravel 5.3 notification to use?
My current attempt is like so:
class FriendRequestCreated extends Notification implements ShouldQueue { use Queueable;
public function toMail($notifiable)
{
// Create mail notification
$message = new MailMessage();
// Mail content
$message -> subject("You have a new friend request!")
-> line("<p>You've received a friend request from:</p>")
-> line("<p>" . $this -> friend -> first_name . " " . $this -> friend -> last_name . "<br />")
-> line($this -> friend -> location() . "</p>")
-> line("<p>Click <a href='" . url("account/home") . "'>here</a>, or go to your account to respond.</p>");
// Return completed email
$this -> queue = "email";
return $message;
}
}
I've then launched a worker like so:
php artisan queue:listen --queue=email
But the job isn't handled.
Please or to participate in this conversation.