Answer the question
In order to leave comments, you need to log in
How to remove related notifications for a post when it is deleted?
Notification box component.
When you comment on an article, notifications come, and they are marked as read,
how can I make sure that when the article is deleted, these notifications are deleted from the table?
After all, a separate id of the article is not written to the table, but everything is written to the data column.
Maybe expand the notifications table and add a separate post id column?
Or is there already a solution?
After all, take all the records and sort through each one, then look for whether there is a post id in this object,
this will be too much load and this is not logical.
Answer the question
In order to leave comments, you need to log in
This is it
$notifications = DB::table('notifications')
->whereJsonContains('data->post_id', $id)
->get();
dd($notifications);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question