working timers

This commit is contained in:
Mark Gregory
2026-06-22 14:26:28 +01:00
parent 0159a638f6
commit 51e074e91c
+6 -5
View File
@@ -36,7 +36,7 @@ class TicketTimer extends Component
/** /**
* Start a database-backed timer for the current authenticated user. * Start a database-backed timer for the current authenticated user.
* *
* @throws \Illuminate\Validation\ValidationException * @throws ValidationException
*/ */
public function startTimer(): void public function startTimer(): void
{ {
@@ -78,7 +78,7 @@ class TicketTimer extends Component
/** /**
* End the current user's active timer and persist seconds/minutes. * End the current user's active timer and persist seconds/minutes.
* *
* @throws \Illuminate\Validation\ValidationException * @throws ValidationException
*/ */
public function endTimer(): void public function endTimer(): void
{ {
@@ -92,9 +92,10 @@ class TicketTimer extends Component
} }
$endedAt = Carbon::now(); $endedAt = Carbon::now();
$seconds = max(1, (int) $timer->started_at->diffInSeconds($endedAt));
$minutes = (int) ceil($seconds / 60);
$description = trim($this->description) !== '' ? trim($this->description) : $timer->description; $description = trim($this->description) !== '' ? trim($this->description) : $timer->description;
$seconds = max(1, (int) $timer->started_at->diffInSeconds($endedAt));
$minutes = (int) ceil($seconds / 60);
$timer->forceFill([ $timer->forceFill([
'ended_at' => $endedAt, 'ended_at' => $endedAt,
@@ -163,7 +164,7 @@ class TicketTimer extends Component
/** /**
* Return the authenticated user or fail validation cleanly. * Return the authenticated user or fail validation cleanly.
* *
* @throws \Illuminate\Validation\ValidationException * @throws ValidationException
*/ */
private function authenticatedUser(): Authenticatable private function authenticatedUser(): Authenticatable
{ {