Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cristo's avatar
Level 13

Column 'notifications.notifiable_id' Not Found (BUG)

I found a problem with Notifications in Spark 3.0. After I create a notification:

$this->notifications->create($user, [
    'icon' => 'fa-check-circle',
    'body' => 'Some text message',
]);     

I see it appear in the sidebar under Notifications. However, when I open it, a request fails behind the scenes:

QueryException in Connection.php line 770:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'notifications.notifiable_id' in 'where clause' (SQL: update `notifications` set `read` = 1, `updated_at` = 2017-01-03 17:02:10 where `notifications`.`notifiable_id` = 6 and `notifications`.`notifiable_id` is not null and `notifications`.`notifiable_type` = App\User and `id` in (<some_id_here...>) order by `created_at` desc)

The failure originates in the NotificationController.php on line 63 at markAsRead method. Any ideas why? I did not do any code customization so I don't see why this would happen.

0 likes
7 replies
ejdelmonico's avatar

File an issue by visiting the repo and following the issue reporting guidelines.

johnfarrar's avatar

What issue did you file, I got the notice also when opening up the notices. It was trying to "PUT" an update that the notice has been read. The field is not available.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'notifications.notifiable_id' in 'where clause' (SQL: update `notifications` set `read` = 1, `updated_at` = 2017-01-04 00:42:39 where `notifications`.`notifiable_id` = 1 and `notifications`.`notifiable_id` is not null and `notifications`.`notifiable_type` = App\User and `id` in (????removed the id ???) order by `created_at` desc)

It looks like the notifiable_type field is also missing.

Swapnil's avatar

Facing the same issue while reading notifications in Laravel Spark.

cristo's avatar
Level 13

Check out the private repo on github, issue #528. It was fixed in this commit.

1 like
avonian's avatar

I'm experiencing the same problem, @cristo's github link doesn't appear to work for me, getting a 404.

cristo's avatar
Level 13

Do you have access to the private spark repo?

dam1r89's avatar

Without deeper investigation what is the cause this is my quick fix. Add this to User model.

    public function notifications()
    {
        return $this->hasMany(\Illuminate\Notifications\DatabaseNotification::class)
            ->orderBy('created_at', 'desc');
    }
2 likes

Please or to participate in this conversation.