Skip to content
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

[8.x] Support delaying notifications per channel #35273

Merged
merged 1 commit into from Nov 19, 2020
Merged

[8.x] Support delaying notifications per channel #35273

merged 1 commit into from Nov 19, 2020

Conversation

iamgergo
Copy link
Contributor

@iamgergo iamgergo commented Nov 18, 2020

Recently I faced the situation, I had to delay the same notification differently on database/email/sms channels.

Currently, there is no easy way to do that, however, we could solve this quite simply. This is a working, but rather conceptional PR, if you find this approach useful, we might polish it further, refactor a bit, update the docblocks, maybe extract the channel delay to its own method, adding tests and so on.


User::first()->notify(
    (new NewOrder(Order::first()))->delay([
        'mail' => now()->addDay(),
        'sms' => 300,
    ])
);
  • This would not be a breaking change – as far as I know
  • If a channel is not present in the delayed values it won't be delayed
  • If the value is not an array, the given delay will be used by all channels (like now)

@taylorotwell taylorotwell merged commit 664e87f into laravel:8.x Nov 19, 2020
@taylorotwell
Copy link
Member

Thank you. Can you send a PR to the documentation?

@iamgergo
Copy link
Contributor Author

Yes, I'll send it soon. Thanks.

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.

None yet

2 participants