CakePHP - 事件的日期和时间time(s) - 如何构建
TLDR:需要了解用户添加日期和日期的最佳方式。事件的时间,以及如何构建数据库
说明: 当用户添加事件时,他们需要能够选择事件的日期,是否每天/每周/每月重复,事件的开始和结束时间或“全天”(如果仅在工作日)或周末...等基本上,当您创建活动时,您可以使用 Google 日历执行所有操作,并且他们也需要能够对其进行编辑(如果这很重要)。但此外,他们还需要能够添加另一个日期/时间 - 例如:
添加一个活动,在本周的周一和周三以及三周后的晚上 8 点到 10 点进行。仅在本周的周二和周四,营业时间为下午 6 点至晚上 9 点。
到目前为止我的想法:
创建一个与我的“事件”表具有 HABTM 关系的“日期”表。当用户添加日期(使用重复等所有选项等)时,它会运行一个函数来处理这些重复/限制等,并将所有日期及其开始/结束时间添加到日期表中。
但是 - 那么如果他们想编辑它,我该如何管理它 - 因为它刚刚创建了多个字段?
:
我是否在正确的轨道上,我是 CakePHP 的新手。 ,而且我很难想出做事的最佳方法...我还没有寻求技术帮助(不过不会拒绝)-现在,我只需要了解一下也许我需要一个“日期”表和一个“时间”表?也许一个带有引用“dates_data”表中许多单独行的“日期”表
?非常提前寻求任何帮助/指导!
TLDR: Need to understand the best way for a user to be able to add a date(s) & time(s) for an event, and how to structure database
Explanation:
When a user adds an event, they need to be able to choose the date of the event, whether or not it will repeat daily/weekly/monthly, start and end time of the event or "all-day", if it's weekdays only or weekend...etc. Basically everything you can do w/ Google calendar when you create an event and they need to be able to edit it too (if that matters). But ALSO, they need to be able to add another date/time - for instance:
Add an event where on Monday and Wednesday of this week and three weeks from now, it goes from 8-10pm. On Tuesday and Thursday this week only, it goes from 6-9pm.
My thoughts so far:
Create a "dates" table with a HABTM relationship w/ my "events" table. When a user adds a date (with all the options of repeat..etc etc., it runs a function to process those repeats/limits...etc and adds all the dates into the dates table w/ their start/end times.
But - then how do I manage it if they want to edit that - since it just created multiple fields.
Question / Help?:
Am I even on the right track with this? I'm new to CakePHP, and it's hard for me to wrap my head around the best ways to do things... I'm not yet looking for technical help (would not turn it down though) - for now, I just need to get the idea for the best way to structure everything to be able to manage this. Maybe I need a "dates" table AND a "times" table? Maybe a "dates" table with an id that references many individual rows in a "dates_data" table?
Thank you very much ahead of time for any help / direction!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你做得很好。让我分享一下我的想法。
如果我要设计这个,我会有 3 个模型:
事件
计划
日期
现在让我们看一个事件的示例。假设我们想要一个将在五月和五月的每个星期六和星期日重复的活动。 2011 年 6 月下午 1:00 至下午 3:00(两小时):
事件表包含事件的基本详细信息。此处将保存一条记录。
时间表表是分开的,以便您可以添加多个时间表。一条记录也将保存在时间表中,其中包含以下字段:
现在,在日期表上,将有 17 条记录,每一条记录对应时间表的一次出现。我之所以把它分开,是为了让我更容易知道事件什么时候发生。例如,在创建日历时,这将很有用。日期表的记录之一如下所示:
现在,如果用户编辑时间表怎么办?日程记录将被编辑。所有日期记录也将被编辑。您不想删除并重新创建日期,因为您可能将每个记录用于另一个模型(例如,用户可能希望将其他用户标记为活动每个日期的参与者)。
我希望这有帮助。祝你的项目好运!
You're doing great. Let me just share my thoughts.
If I would design this, I'd have 3 models:
Event
Schedule
Date
Now let's have an example of an event. Let's say we want an event that will repeat every Saturday and Sunday of May & June 2011 at 1:00pm until 3:00pm (two hours):
The events table contains the basic detail of an event. One record will be saved here.
The schedules table is separated so that you could add multiple schedules. One record will also be saved in schedule with the following fields:
Now on dates table, there will be 17 records, one for each occurrence of the schedule. The reason why I separated this is that it will be easier for me know when will the event fall. This will be useful, for example, when creating the calendar. One of the records for the dates table will look like this:
Now what if the user edits the schedule? The schedule record would be edited. All dates record would also be edited. You don't wanna delete and recreate the dates, since you might use each record for another model (e.g. user might want to tag other users as attendees for each date of the event).
I hope this helps. Goodluck on your project!