Skip to content

Commit 0563759

Browse files
committed
Patch: Mark a ticket and comments as read don't change updated_at field
1 parent ad56682 commit 0563759

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/Controllers/TicketsController.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1879,17 +1879,32 @@ public function show($id)
18791879
$a_resend_notifications = $this->get_resend_notifications($ticket, $all_comments);
18801880

18811881
if ($this->member->currentLevel() > 1 and $this->member->id == $ticket->agent_id and $ticket->read_by_agent == '0'){
1882+
// Disable changing the updated_at field
1883+
$ticket->timestamps = false;
1884+
18821885
// Mark ticket as read
18831886
$ticket->read_by_agent = 1;
18841887
$ticket->save();
18851888

1886-
// Mark comments as read
1889+
18871890
foreach ($all_comments->get() as $comment){
18881891
if ($comment->read_by_agent != '1'){
1892+
// Disable changing the updated_at field
1893+
$comment->timestamps = false;
1894+
// Disable changing related ticket updated_at via $touches array in Comment model
1895+
$comment->setTouchedRelations([]);
1896+
1897+
// Mark comments as read
18891898
$comment->read_by_agent = 1;
18901899
$comment->save();
1900+
1901+
// Enable created_at and updated_at for view
1902+
$comment->timestamps = true;
18911903
}
18921904
}
1905+
1906+
// Enable created_at and updated_at for view
1907+
$ticket->timestamps = true;
18931908
}
18941909

18951910
$data = compact('ticket', 'a_reasons', 'a_tags_selected', 'status_lists', 'complete_status_list', 'agent_lists', 'tag_lists',

0 commit comments

Comments
 (0)