transactions->run(function () use ($userId, $taskId, $date, $parsed, $note): string { $task = $this->booking->openTask($taskId); $this->booking->ensureDayFits($userId, $date, $parsed); $entry = $this->entries->findForDay($userId, $taskId, $date); if ($entry === null) { $entry = TimeEntry::create($userId, $taskId, $task->jobId, $task->workTypeId, $date, $parsed, $note); } else { $entry->addHours($parsed, $note); } return $this->entries->save($entry)->hours()->format(); }); } }