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

Allow declaring custom or multiple notification classes in health.php #200

Merged
merged 6 commits into from
Nov 3, 2023

Conversation

christosku
Copy link
Contributor

@christosku christosku commented Oct 25, 2023

BUG: When trying to create a custom notification for laravel-health I found out that RunHealthChecksCommand getFailedNotificationClass() returns a hardcoded Spatie\Health\Notifications\CheckFailedNotification::class which makes it impossible to override with your own notification.

  • Make getFailedNotificationClass() return the first key (class name) from config('health.notifications.notifications')

This change should not have any effect in existing installations but would allow users to use their own notification by declaring it inside health.php:

'notifications' => [
    App\Notifications\CustomCheckFailedNotification::class => ['mail','teams','signal','irc'],
],

@freekmurze I went through the documentation and code and couldn't find another way to do this, other than creating a custom command, but that seemed like an overkill and maybe this could help others who need custom notifications.

@christosku christosku marked this pull request as ready for review October 25, 2023 15:07
@freekmurze
Copy link
Member

Multiple notification classes seem overkill to me. Could you refactor this so there can be only one notification class?

@christosku
Copy link
Contributor Author

Done!

@freekmurze freekmurze merged commit 4adda72 into spatie:main Nov 3, 2023
@freekmurze
Copy link
Member

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.

2 participants