Filament Database Notifications
I would like to use the Database Notifications as described in the docs here:
https://filamentphp.com/docs/3.x/notifications/database-notifications
However, the migration creates a database table called "notifications" and we already have a database table of that name. I can of course change it in the migration but presumably Filament will be looking for the "notifications" table rather than the one I create.
Can anyone tell me if it is possible to customise this, please?
Thank you.
2 Replies
Based on a brief code analysis (but not on any attempted personal experience), I'm pretty sure it's not possible.
here's why:
As of Filament 3.1 the DatabaseNotificationModel is hard-coded to Laravel's internal one, which has the tablename hardcoded into it.
So customization is not currently possible.
https://github.com/filamentphp/filament/blob/d88debaf627171ce183216205f48ec76b49b785f/packages/notifications/src/DatabaseNotification.php#L8
https://github.com/filamentphp/filament/blob/d88debaf627171ce183216205f48ec76b49b785f/packages/notifications/src/Notification.php#L14
If that were configurable to a userland model (ie: one that you could create to extend Laravel's original model), then you could follow the usual advice given publicly for how to override that tablename in Laravel:
https://stackoverflow.com/a/51029649
https://github.com/laravel/framework/issues/15847
Stack Overflow
How to change default notification table name in Laravel
I want to change notification table name, so I changed the migration file:
php artisan notification:table
Schema::create('member_notifications', function (Blueprint $table) {
$table->uui...
GitHub
How to override the notification table name · Issue #15847 · larav...
Laravel Version: 5.3.* PHP Version: 5.6 Database Driver & Version: mysql Description: I wanted to override the default table for notification. I was not able to find it anywhere on the internet...
GitHub
filament/packages/notifications/src/DatabaseNotification.php at d88...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
GitHub
filament/packages/notifications/src/Notification.php at d88debaf627...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
Thank you very much for your reply.