add duration
This commit is contained in:
@@ -19,6 +19,7 @@ class ToDoResource extends JsonResource
|
||||
'user_id' => $this->user_id,
|
||||
'name' => $this->name,
|
||||
'checked' => $this->checked,
|
||||
'duration' => $this->duration,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user