How to store time, and manipulate it -- not time travel related ;)

Posted 2 years ago by steveperrycreative

I'm re-writing an application for my business which helps me manage website maintenance plans for my clients.

These plans differ, depending upon what the client requires. Some are just software updates and some include discounted monthly hours of my time. Standard stuff.

I add projects to the application, which then have tasks added to them and I have a plan associated to the project. Those tasks, when added, subtract time from the client's accumulated balance of hours. The balance of hours should auto-accumulate each month based upon the associated plan.

To complicate matters a little, some of these plans have their hours reset after 3 months of accumulation, but not all of them.

Project views show all tasks (with time used on them), the current plan, accumulated hours and hours/mins remaining.

My question is how should I store this time so that I can retrieve it and manipulate where required. It would be nice if I could even retrieve the hours that have been reset (just for reports etc).

In the past I just stored a number which related to the number of hours allowed each month and did some basic maths when loading the views but this was obviously very restricted so I'm keen to hugely improve in v2.

Should I create a Time model? How would this work with a cron, which I guess I'll also need to keep the hours adding up in the background?

Any pointers really appreciated as I'm struggling to get my head around it a bit. I'm still relatively new to Laravel and OOP in general.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.