add duration

This commit is contained in:
Romulus21 committed 2024-02-15 23:09:13 +01:00
1 parent b326f79f2d
commit 335fc8b12b
5 files changed
+42 -3

No files matched your search

+6 -1
View File
@@ -58,7 +58,12 @@ class User extends Authenticatable
public function stopCurrentTimeTracker(): void
{
$this->currentTimeTracker()->update(['end_at' => now()]);
$end = now();
$delay = $end->diffInSeconds($this->currentTimeTracker->start_at);
$toDo = $this->currentTimeTracker->toDo;
$toDo->duration = $toDo->duration + $delay;
$toDo->save();
$this->currentTimeTracker()->update(['end_at' => $end]);
$this->time_tracker_id = null;
$this->save();
}