Skip to content

Conversation

@jackbayliss
Copy link
Contributor

@jackbayliss jackbayliss commented Nov 8, 2025

The other day I was trying to find a nice way to make all my Mailables go to one queue, and Notifications to go to another.

Which, got me thinking rather than creating new base classes to extend them for all my mail / notifications classes- and then using onQueue / settings the queue property, I thought it could be nice to have this as a static property so it can be setup in the service provider and defaulted.

This also means if anyone creates a new Mailable, or Notification in my application - there's no ability to forget to extend the base class (as there isnt one!)

This means we can do something like the below and not worry about the queue as it'll default to what we set:
Mail::to($user->email)->queue(new X);
Notification::send($users, new InvoicePaid($invoice));

I don't think this is a breaking change, as it's null by default so continues on as normal if its not set.

Let me know if there's any adjustments needed / a better way 🫡

Something like this may also work for Jobs, and could sit in a config - but one step at a time.

@github-actions
Copy link

github-actions bot commented Nov 8, 2025

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@jackbayliss jackbayliss force-pushed the mail-and-notfication-default-queues branch from 111c66e to 2ba8e5c Compare November 8, 2025 17:06
@jackbayliss jackbayliss marked this pull request as ready for review November 8, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant