Witam.
Mam w aplikacji funkcję powiadamiania użytkownika o tym, że inny użytkownik skomentował jego post. W przypadku usunięcia danego postu powiadomienie o komentarzu dalej pozostaję. Chciałbym aby wraz z postem usunięte zostało powiadomienie.
Znalazłem na forum podobny wątek
https://laracasts.com/discuss/channels/laravel/deleting-notifications-for-a-deleted-model
analogicznie użyłem tego w swoim przypadku, tj.
$post->user->notifications()
->where('type', 'App\Notifications\CommentAdded')
->where('data->post_id', $post->id)
->delete();
Niestety wyświetla mi się błąd bazy danych
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '>'$."post_id"' = ? order by `created_at` desc' at line 1 (SQL: delete from `notifications` where `notifications`.`notifiable_id` = 72 and `notifications`.`notifiable_id` is not null and `notifications`.`notifiable_type` = App\User and `type` = App\Notifications\CommentAdded and `data`->'$."post_id"' = 5 order by `created_at` desc).
Dodam że w tabeli Notifications w kolumnie "data" jest id tego postu
Z góry dziękuję za pomoc/