F
Filament5mo ago
Jakub

What does register in service provider mean?

Is this something only for fillament panels? I am trying to get the notification count working
// views/components/trigger
<button x-data="{}" class="text-white" x-on:click="$dispatch('open-modal', { id: 'database-notifications' })"
type="button">
Notifications ( {{ $unreadNotificationsCount }} unread)
</button>
// views/components/trigger
<button x-data="{}" class="text-white" x-on:click="$dispatch('open-modal', { id: 'database-notifications' })"
type="button">
Notifications ( {{ $unreadNotificationsCount }} unread)
</button>
AppServiceProvider.php
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Filament\Notifications\Livewire\DatabaseNotifications;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
DatabaseNotifications::trigger('components.trigger');
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{

}
}
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Filament\Notifications\Livewire\DatabaseNotifications;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
DatabaseNotifications::trigger('components.trigger');
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{

}
}
I got things working for the most part, as I am able to click the trigger, and the modal opens and i see the notifications. Just trynig to make the count part work. Trying to make this work in a livewire app that i just installed fillament onto. Not a fresh fillament app.
No description
1 Reply
Jakub
Jakub5mo ago
Oof, just figured it out. For anyone in the future. After you register the component you made in App Service Provider . This part in the docs
@livewire('database-notifications')
@livewire('database-notifications')
This isn't a script u add to the bottom of app file like the other fillament things. This is going to show the actual button you designed. 1. So you need to design your buttton, 2. register it in ap pserivce provider 3. use @livewire('database-notifications') where you want that button to be