add duration

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

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();
}