简体   繁体   English

使用Laravel 5在Notification系统中标记is_read

[英]Mark is_read in Notification system with Laravel 5

I have a site where users can post things like statuses, pictures, etc. I'm wan't to create a notification system similar to Facebook . 我有一个网站,用户可以在其中发布状态,图片等内容。我不会创建类似于Facebook的通知系统。 Something that alerts the user of their friends recent activity. 提醒用户其朋友最近活动的信息。 My problem is i'm not sure how I should structure my table. 我的问题是我不确定如何构造表。 I'm following some advice from an older tutorial Tutorial for the db scheme, and doing something like this 我正在从旧的教程教程中获取有关db方案的建议,并执行类似的操作

id | id | user_id | user_id | subject | 主题| body | 身体| object_id | object_id | object_type | object_type | is_read | is_read | sent_at | sent_at | created_at | created_at | updated_at Updated_at

I know what to do for the majority of the code, or at least have a good idea, my problem and question is for the is_read column, should i create a separate table to store that information, if not then how can I mark a notification as is_read with the current setup. 我知道对大多数代码该怎么做,或者至少有一个好主意,我的问题是针对is_read列,我是否应该创建一个单独的表来存储该信息,如果不能,那么如何标记通知与当前设置的is_read一样。

I guess you want to have a "is read" for EVERY friend/user, this was a bit unclear. 我想您想为每个朋友/用户都读一遍,这还不清楚。 If this is the case your best bet (in my opinion) would be to create a new table, as you said, containing the post_id, and user_id. 如果是这种情况,您最好的选择(我认为)是按照您所说的创建一个新表,其中包含post_id和user_id。 All you then have to do is to check is such a relationship exists, and if so, show a notification. 然后,您要做的就是检查这种关系是否存在,如果存在,则显示一条通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM