Database notifications not working
I created an Exporter and it seems to be working fine (meaning I have the csv file on the public disk) but I never get the notification that the download is complete and a link to download like it is suppose to work. I do not have any errors in the logs or anywhere else, the job dispatches and is completed fine, I do have the notification in the database but never gets pulled into the notifications panel
Solution:Jump to solution
Not sure why the job uses
App\Models\User
though. I think it would be best to remove that again and solve the issue with App\User
not working. What was the original error?29 Replies
Is your queue running? Or it the queue driver set to
sync
?
Sounds like it is when the job is processed throught the queue.
You enabled DB notifications for the panel?is redis
db is enabled
db notifications*
but I use redis
should it be set to sync ?
No as long as your queue is running
it is and none of the jobs is failing
So the notification icon just shows up empty?
yes
Is the notification for the right user?
but in the notifications table I do have a new record
Yes it is for the right user
I get the correct user id
Hm, very weird
Might be an issue with UUIDs? 🤔
shouldn't that error out ?
I now see the Notifiable type is App\Models\User. My User model is in App\User and what I did is to create another User.php class in App\Models\ and just extend the original user.
But I guess that's fine since I get the correct user id and nothing is erroring out
because before the job was failing due to not being able to find App\Models\User
Um. That might be an issue, because the Auth Guard probably returns
App\User
thenI also bind Authenticable in service provider to the correct User model
What model does
Filament::auth()
return?I doubt the solution is to create 2 classes. What was the acutal error?
The DatabaseNotification component should use the current auth guard:
What is the class of
filament()->auth()->user()
?
Tried this and it returns null
and I tried this:
And it hits the return statement "No authenticated user"
Well, thats not a Filament route, is it?
Nope
where would be the best place to check this ?
On any Filament page. You could add a
dd()
to the mount()
or to a form.ok it is getting
App\User
That's why it can't find your notification.
Solution
Not sure why the job uses
App\Models\User
though. I think it would be best to remove that again and solve the issue with App\User
not working. What was the original error?ok let me remove that and get the original error one sec
/filament/actions/src/Exports/Models/Export.php:54
in AppServiceProvider I added the following: $this->app->bind(Authenticatable::class, User::class);
but I still get the same errroYou imported the namespace?
Can you show more code around the binding? Did you put it inside a
Filament::serving()
What does app(Illuminate\Contracts\Auth\Authenticatable::class)
return when called from a page or similar?well it is in Laravel's app service provider
inside the register method
app > Providers > AppServiceProvider.php > register()
I now added it to a Filament::serving() but same problem
Now when I start the queue I get No [App\Models\User] model found. Please bind an authenticatable model to the [Illuminate\Contracts\Auth\Authenticatable] interface in a service provider's [register()] method
So it works?
Did you restart the queue the last time after the change?
yes. It looks like it's working now. not sure what I did 😄
Thanks a lot for your help