简体   繁体   中英

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 . 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

id | user_id | subject | body | object_id | object_type | is_read | sent_at | created_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.

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. All you then have to do is to check is such a relationship exists, and if so, show a notification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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