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:
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?
Jump to solution
29 Replies
Dennis Koch
Dennis Koch4mo ago
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?
mvpopuk
mvpopukOP4mo ago
is redis db is enabled db notifications* but I use redis should it be set to sync ?
Dennis Koch
Dennis Koch4mo ago
No as long as your queue is running
mvpopuk
mvpopukOP4mo ago
it is and none of the jobs is failing
Dennis Koch
Dennis Koch4mo ago
So the notification icon just shows up empty?
mvpopuk
mvpopukOP4mo ago
yes
Dennis Koch
Dennis Koch4mo ago
Is the notification for the right user?
mvpopuk
mvpopukOP4mo ago
but in the notifications table I do have a new record Yes it is for the right user I get the correct user id
Dennis Koch
Dennis Koch4mo ago
Hm, very weird
mvpopuk
mvpopukOP4mo ago
No description
Dennis Koch
Dennis Koch4mo ago
Might be an issue with UUIDs? 🤔
mvpopuk
mvpopukOP4mo ago
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
Dennis Koch
Dennis Koch4mo ago
Um. That might be an issue, because the Auth Guard probably returns App\User then
mvpopuk
mvpopukOP4mo ago
I also bind Authenticable in service provider to the correct User model
Dennis Koch
Dennis Koch4mo ago
What model does Filament::auth() return?
mvpopuk
mvpopukOP4mo ago
<?php

namespace App\Models;

use App\User as BaseUser;

class User extends BaseUser
{
// This is for filament
}
<?php

namespace App\Models;

use App\User as BaseUser;

class User extends BaseUser
{
// This is for filament
}
Dennis Koch
Dennis Koch4mo ago
I doubt the solution is to create 2 classes. What was the acutal error? The DatabaseNotification component should use the current auth guard:
public function getUser(): Model | Authenticatable | null
{
return auth(static::$authGuard)->user();
}
public function getUser(): Model | Authenticatable | null
{
return auth(static::$authGuard)->user();
}
What is the class of filament()->auth()->user()?
mvpopuk
mvpopukOP4mo ago
Route::get('/test-filament-user', function () {
$user = filament()->auth()->user();

return get_class($user);
});
Route::get('/test-filament-user', function () {
$user = filament()->auth()->user();

return get_class($user);
});
Tried this and it returns null and I tried this:
Route::get('/test-filament-user', function () {
if (filament()->auth()->check()) {
$user = filament()->auth()->user();

return get_class($user);
}

return 'No authenticated user';
});
Route::get('/test-filament-user', function () {
if (filament()->auth()->check()) {
$user = filament()->auth()->user();

return get_class($user);
}

return 'No authenticated user';
});
And it hits the return statement "No authenticated user"
Dennis Koch
Dennis Koch4mo ago
Well, thats not a Filament route, is it?
mvpopuk
mvpopukOP4mo ago
Nope where would be the best place to check this ?
Dennis Koch
Dennis Koch4mo ago
On any Filament page. You could add a dd() to the mount() or to a form.
mvpopuk
mvpopukOP4mo ago
ok it is getting App\User
Dennis Koch
Dennis Koch4mo ago
That's why it can't find your notification.
Solution
Dennis Koch
Dennis Koch4mo ago
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?
mvpopuk
mvpopukOP4mo ago
ok let me remove that and get the original error one sec
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. {"exception":"[object] (Exception(code: 0): 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.
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. {"exception":"[object] (Exception(code: 0): 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.
/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 errro
Dennis Koch
Dennis Koch4mo ago
You 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?
mvpopuk
mvpopukOP4mo ago
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
Filament::serving(function () {
$this->app->bind(Authenticatable::class, User::class);
});
Filament::serving(function () {
$this->app->bind(Authenticatable::class, User::class);
});
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
Dennis Koch
Dennis Koch4mo ago
So it works? Did you restart the queue the last time after the change?
mvpopuk
mvpopukOP4mo ago
yes. It looks like it's working now. not sure what I did 😄 Thanks a lot for your help
Want results from more Discord servers?
Add your server