Like 4-5 minutes ago I was lookin at this post Best Way To Build A Multi-Notification System in PHP and I was playing around with it to see how it would work in my website. so far it would work great although I wanted to know how to get the id to link back to where to notification took place at. For example say i leave a comment on user 1's photo and when user 1 looks in notification it shows i commented on one of his photo but how would he know which one exactly. Now I would foreign key and add another column but i would have to do this for every other type of notification "tagging, in a photo","liking a photo", "comment in profile", "sending a message", etc... unless i have to.
就像4-5分钟前我一直在看这篇文章用PHP构建一个多通知系统的最佳方式我正在玩它以了解它在我的网站中是如何工作的。到目前为止它会工作得很好虽然我想知道如何将id链接回到通知发生的位置。例如,假设我对用户1的照片发表评论,当用户1查看通知时,它显示我评论了他的一张照片,但他怎么会知道哪一张照片。现在我将外键并添加另一列,但我必须为每个其他类型的通知“标记,在照片中”,“喜欢照片”,“在个人资料中评论”,“发送消息”等等。 ..除非我必须。
1 个解决方案
#1
0
Maybe it is best was to add Notifications model that would have fileds like this
也许最好是添加具有这样的文件的通知模型
object_type
object_id
user_id
object_type would be reference to type of what user commented (post,photo,etc..) it can be string...
object_type将引用用户注释的类型(帖子,照片等)。它可以是字符串...
Hope it helps...
希望能帮助到你...
#1
0
Maybe it is best was to add Notifications model that would have fileds like this
也许最好是添加具有这样的文件的通知模型
object_type
object_id
user_id
object_type would be reference to type of what user commented (post,photo,etc..) it can be string...
object_type将引用用户注释的类型(帖子,照片等)。它可以是字符串...
Hope it helps...
希望能帮助到你...