I
I
Ivan Vovchok2020-07-27 16:25:02
Laravel
Ivan Vovchok, 2020-07-27 16:25:02

How to add time tracking feature in Laravel?

Greetings gentlemen!

The task is quite trivial, but due to the lack of sufficient experience in Laravel at this stage, I decided to ask those who know.

What should be done?
There is an application where users perform the same type of tasks. The start and end of work are carried out by clicking on the button. It is necessary to attach triggers to these buttons to start the tracker, which will record the time that has passed between the start and end of work. Data must be stored in the database with reference to a specific task and the user who did it.
I've seen a lot of people recommend using Vue, but I'd still prefer to get by with pure JS if it doesn't make sense.

What did I do?
1. Created a table for timers with columns 'id', 'task_id','user_id', 'started_at'and 'stopped_at', where 'task_id'and 'user_id'are foreign keys from the corresponding tables.
2. Described the Timer model, added everything you need there.
3. I created a controller, but I'm not quite sure which methods I need in this situation.

I am also interested in how to most correctly implement the process of counting time and how to transfer it to the database.

Thank you for your attention!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Darkhan Kamaliev, 2020-07-27
@Vanovich

What's the problem? 2 methods, conditional Timer start\stop(pause?). End date and time by default Null, after the end of the task, show the total elapsed time. Until the end on js, you determine the difference between the current time and the start time of the task. May the Carbon be with you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question