Skip to content

Commit 7939bda

Browse files
committed
remove consecutive hide comments
1 parent a2abeea commit 7939bda

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/Controllers/TicketsController.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,14 +1484,22 @@ public function hide($value, $id)
14841484
*/
14851485
public function hide_actions($ticket)
14861486
{
1487-
$user = $this->member->find(auth()->user()->id);
1487+
$member = $this->member->find(auth()->user()->id);
1488+
1489+
$latest = Models\Comment::where('ticket_id', $ticket->id)->where('user_id', $member->id)->orderBy('id', 'desc')->first();
1490+
1491+
if (in_array($latest->type, ['hide_0', 'hide_1'])){
1492+
// Delete last comment for consecutive ticket hide and show for user
1493+
$latest->delete();
1494+
return false;
1495+
}
14881496

14891497
// Add hide/notHide comment
14901498
$comment = new Models\Comment;
14911499
$comment->type = "hide_".$ticket->hidden;
14921500
$comment->content = $comment->html = trans('panichd::lang.ticket-hidden-'.$ticket->hidden.'-comment');
14931501
$comment->ticket_id = $ticket->id;
1494-
$comment->user_id = $user->id;
1502+
$comment->user_id = $member->id;
14951503
$comment->save();
14961504
}
14971505

0 commit comments

Comments
 (0)