且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel多对多关系查询

更新时间:2023-02-15 18:21:04

好吧,除了活动跟踪之外,您几乎可以对所有内容进行排序.所以,这是我的建议:

Well, you have pretty much everything sorted except the activity tracking. So, here's what I propose:

用户表

带有列ID,名称,电子邮件等

with columns id, name, email, etc

活动表

带有列ID,名称等

用户活动表(枢轴)

user_activity table (pivot)

具有列ID,用户ID,活动ID等 该表将包含用户和活动之间的多对多映射.

with columns id, user_id, activity_id, etc This table will contain the many to many mapping between users and activities.

activity_tracking

activity_tracking

具有列ID,user_activity_id,状态,updated_at等 在这里,您可以使用整数值表示状态,比如说1.然后,使用updated_at和created_at可以跟踪活动的开始和完成时间.

with columns id, user_activity_id, status, updated_at etc Here you could use an integer value for status to signify completion lets say 1. And using updated_at and created_at you could track activity start and completion timing.