F
Filamentβ€’16mo ago
Robin

Notifications reduction of amount of showed notifications

Is it possible to (simply) reduce the amount of showed notifications in the sidebar? I'd like to only show the unread notifications or the notifications that are seen but then a cutoff in creation age of like 1 week or so. Is this possible and how?
10 Replies
Patrick Boivin
Patrick Boivinβ€’16mo ago
I don't think there's a simple solution for this... If you're willing to dig into the internals, I think you can probably override the Notifications component: https://github.com/filamentphp/filament/blob/2.x/packages/notifications/src/Http/Livewire/Notifications.php#L83-L87
Robin
RobinOPβ€’16mo ago
Oh dear. So I'd need to extend that one in "my application" and override the methods I want, if I understand correctly?
Patrick Boivin
Patrick Boivinβ€’16mo ago
Yes, not a great solution, more like a hack currently πŸ˜…
Robin
RobinOPβ€’16mo ago
Now I do wonder, how do I "use" or "register" it then? πŸ˜…
Patrick Boivin
Patrick Boivinβ€’16mo ago
I can give you some tips but you'll be on your own to experiment. Would that be ok? lol
Robin
RobinOPβ€’16mo ago
yes, ofcource! I'll experiment with it, it's going to be fun πŸ˜›
Patrick Boivin
Patrick Boivinβ€’16mo ago
Add a Notifications class to your project, for example in app/Http/Livewire/Filament/Notifications.php:
namespace App\Http\Livewire\Filament;

use Filament\Notifications\Http\Livewire\Notifications as BaseNotifications;

class Notifications extends BaseNotifications
{
// Customize anything here
}
namespace App\Http\Livewire\Filament;

use Filament\Notifications\Http\Livewire\Notifications as BaseNotifications;

class Notifications extends BaseNotifications
{
// Customize anything here
}
This class extends the built-in Livewire component. Then, re-bind the Livewire component in your AppServiceProvider:
public function boot()
{
Livewire::component('filament.core.notifications', \App\Http\Livewire\Filament\Notifications::class);

// ...
}
}
public function boot()
{
Livewire::component('filament.core.notifications', \App\Http\Livewire\Filament\Notifications::class);

// ...
}
}
It's important to do it in boot()
Robin
RobinOPβ€’16mo ago
I see, thanks, I'll try to apply some magic tomorrow with it! Hmm, Seems like it doesn't register it anymore then
Patrick Boivin
Patrick Boivinβ€’16mo ago
I think I made a little mistake Should probably be
use Filament\Http\Livewire\Notifications as BaseNotifications;
use Filament\Http\Livewire\Notifications as BaseNotifications;
Robin
RobinOPβ€’16mo ago
Jep! that did the trick! Awesome, thanks!
Want results from more Discord servers?
Add your server