-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[9.x] Added ability to set delay per channel based on notifiable instance #42239
Conversation
Was there a reason you named the method |
@taylorotwell |
… notification-channel-delay
I think |
The reason I mentioned It would also break any current use of notifications that has the Queueable-trait as it would be calling a setter-method instead of getting the desired delays per channel |
Ah - I didn't consider that. 👍 |
@ehamrin got it |
We have a lot of users who don't want to receive Notification emails during the night, and some that does.
After some digging this is a solution to bypass the current behaviour:
Trying to set a delay based on a notifiable instance currently required the delay to be set in
$notification->via()
as it is the last method called where the notifiable is passed through. It is however not optimal as it is set on the $original instance in NotificationSender::186, so it must be overwritten in every via-call on every notifiable.My proposal is a new method call
withDelay
that accepts the notifiable and channel as arguments which provides:To me there are only upsides, if there are database queries performed or heavy logic to resolve the delay it's only calculated once if the developer choose to match against the channel name provided. The code looks cleaner as well, the
via
method doesn't become cluttered with delay data.It does not break the existing implementation by setting the delay prop.
Only breaking change would be if someone has implemented a withDelay function in a notification to solve something else.