phases one of time logged
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Modules\Helpdesk\Livewire;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\CarbonInterval;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -316,6 +317,7 @@ final class TicketShow extends Component
|
||||
]) ?? $ticket;
|
||||
|
||||
$this->hydrateTicketUsers($ticket);
|
||||
|
||||
$comments = $ticket->comments()
|
||||
->active()
|
||||
->when(! $this->canSeeInternalNotes(), static function ($query): void {
|
||||
@@ -324,26 +326,31 @@ final class TicketShow extends Component
|
||||
->with(['user.company', 'attachments', 'replies.user.company', 'replies.attachments'])
|
||||
->oldest()
|
||||
->get();
|
||||
$ticket->setRelation('comments', $comments);
|
||||
|
||||
$ticket->setRelation('comments', $comments);
|
||||
$ticket->setAttribute('public_replies_count', $comments->where('is_internal', false)->count());
|
||||
$ticket->setAttribute('time_spent_minutes', $this->sumCommentMinutes($comments));
|
||||
$ticket->setAttribute('time_spent_minutes', (int) $ticket->getRawOriginal('time_spent_minutes'));
|
||||
$ticket->setRelation('comments', $this->buildCommentTree($comments->groupBy('parent_id')));
|
||||
|
||||
return $ticket;
|
||||
}
|
||||
|
||||
private function sumCommentMinutes(Collection $comments): int
|
||||
|
||||
public function formattedTimeSpent(): string
|
||||
{
|
||||
if (Schema::hasColumn('helpdesk_comments', 'time_spent_minutes')) {
|
||||
return (int) $comments->sum('time_spent_minutes');
|
||||
$minutes = (int) $this->ticket->time_spent_minutes;
|
||||
|
||||
if ($minutes < 1) {
|
||||
return '0 minutes';
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('helpdesk_comments', 'minutes_logged')) {
|
||||
return (int) $comments->sum('minutes_logged');
|
||||
}
|
||||
|
||||
return 0;
|
||||
return CarbonInterval::minutes($minutes)
|
||||
->cascade()
|
||||
->forHumans([
|
||||
'short' => false,
|
||||
'parts' => 2,
|
||||
'join' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
private function hydrateTicketUsers(Ticket $ticket): void
|
||||
|
||||
Reference in New Issue
Block a user