Custom DatabaseNotification class

Hi. I need to use a custom DatabaseNotification class instead of this: https://github.com/filamentphp/filament/blob/3.x/packages/notifications/src/DatabaseNotification.php.
I've tried extending the Filament\Notifications\Notification class and overriding the toDatabasemethod but it's return typed, which makes it difficult:
toDatabase() must be compatible with Filament\Notifications\Notification::toDatabase(): Filament\Notifications\DatabaseNotification
toDatabase() must be compatible with Filament\Notifications\Notification::toDatabase(): Filament\Notifications\DatabaseNotification
Any ideas on how to work around this? Alternatively I'm wondering if I should submit a PR to remove the typing.
8 Replies
toeknee
toeknee15mo ago
If you read it... you haven't made it compatible. I.e. each function being used must mirror it from the construction point. I suspect you are missing the params of the function
Xiquita
Xiquita15mo ago
you have to call databasenotification in AdminPanelProvider and create the notification function on the resource creation page
binaryfire
binaryfireOP15mo ago
It's not compatible because I'm using a custom class instead of Filament\Notifications\DatabaseNotification. That's my point- the method is return typed to Filament\Notifications\DatabaseNotification which makes overriding it difficult. I need to use my own class because I'm using custom schema-based tenancy. And a custom database notification channel to make notifications tenant-aware.
Xiquita
Xiquita15mo ago
use Filament\Notifications\Notification;
binaryfire
binaryfireOP15mo ago
I am. That's not the issue.
Xiquita
Xiquita15mo ago
protected function getCreatedNotification(): ?Notification
binaryfire
binaryfireOP15mo ago
All good. Submitted a PR- will see what the maintainers say on GitHub.
Xiquita
Xiquita15mo ago
ok
Want results from more Discord servers?
Add your server