@php use Illuminate\Support\Facades\Schema; use Modules\Helpdesk\Models\TicketTimeLog; $ticketTimeLogTable = (new TicketTimeLog())->getTable(); $hasEndedAtColumn = Schema::hasColumn($ticketTimeLogTable, 'ended_at'); $hasStoppedAtColumn = Schema::hasColumn($ticketTimeLogTable, 'stopped_at'); $hasFinishedAtColumn = Schema::hasColumn($ticketTimeLogTable, 'finished_at'); $hasUserIdColumn = Schema::hasColumn($ticketTimeLogTable, 'user_id'); $runningTimerQuery = TicketTimeLog::query() ->where('ticket_id', $ticket->getKey()) ->whereNotNull('started_at') ->orderByDesc('started_at'); if ($hasUserIdColumn) { $runningTimerQuery->where('user_id', auth()->id()); } if ($hasEndedAtColumn) { $runningTimerQuery->whereNull('ended_at'); } if ($hasStoppedAtColumn) { $runningTimerQuery->whereNull('stopped_at'); } if ($hasFinishedAtColumn) { $runningTimerQuery->whereNull('finished_at'); } $runningTimer = ($hasEndedAtColumn || $hasStoppedAtColumn || $hasFinishedAtColumn) ? $runningTimerQuery->first() : null; $runningTimerStartedAt = $runningTimer?->started_at; $runningTimerElapsedSeconds = $runningTimerStartedAt ? max(0, now()->diffInSeconds($runningTimerStartedAt)) : 0; $runningTimerElapsedDisplay = gmdate('H:i:s', $runningTimerElapsedSeconds); $hasRunningTimer = $runningTimerStartedAt !== null; @endphp @can('update', $ticket) Ticket controls Log time, assignment, status and priority Running {{ $runningTimerElapsedDisplay }} @if (session('ticket-action-updated')) {{ session('ticket-action-updated') }} @endif @if ($hasRunningTimer) Timer running Started {{ $runningTimerStartedAt->format('d M Y H:i:s') }} {{ $runningTimerElapsedDisplay }} Elapsed @endif @include('helpdesk::partials.ticket-time-timer', [ 'ticket' => $ticket, ]) @csrf Log time Log @error('minutes') {{ $message }} @enderror @error('description') {{ $message }} @enderror @csrf Assigned agent Unassigned @forelse ($agents as $agent) id)>{{ $agent->name }} ยท {{ $agent->email }} @empty No users available for assignment @endforelse @error('agent_id') {{ $message }} @enderror Assign agent @csrf Status @foreach ($statuses as $status) id)>{{ $status->name }} @endforeach @error('status_id') {{ $message }} @enderror Update status @csrf Priority @foreach ($priorities as $priority) id)>{{ $priority->name }} @endforeach @error('priority_id') {{ $message }} @enderror Update priority @endcan
Log time, assignment, status and priority
Timer running
Started {{ $runningTimerStartedAt->format('d M Y H:i:s') }}
{{ $runningTimerElapsedDisplay }}
Elapsed
{{ $message }}