|
|
|
|
|
|
|
|
public function isTicketUnread(Ticket $ticket, User $user): int |
|
|
public function isTicketUnread(Ticket $ticket, User $user): int |
|
|
{ |
|
|
{ |
|
|
$ticketUser = $this->getTicketUser($ticket, $user); |
|
|
$ticketUser = $this->getTicketUser($ticket, $user); |
|
|
|
|
|
|
|
|
if($ticketUser) { |
|
|
if($ticketUser) { |
|
|
foreach($ticket->ticketMessages as $ticketMessage) { |
|
|
foreach($ticket->ticketMessages as $ticketMessage) { |
|
|
if($this->isTicketMessageUnread($ticketMessage, $ticketUser)) { |
|
|
if($this->isTicketMessageUnread($ticketMessage, $ticketUser)) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getFirstTicketMessageUnread(Ticket $ticket, User $user): ?TicketMessage |
|
|
public function getFirstTicketMessageUnread(Ticket $ticket, User $user): ?TicketMessage |
|
|
{ |
|
|
{ |
|
|
$ticketUser = $this->getTicketUser($ticket, $user); |
|
|
$ticketUser = $this->getTicketUser($ticket, $user); |
|
|
|
|
|
|
|
|
if($ticketUser) { |
|
|
if($ticketUser) { |
|
|
foreach($ticket->ticketMessages as $ticketMessage) { |
|
|
foreach($ticket->ticketMessages as $ticketMessage) { |
|
|
if($this->isTicketMessageUnread($ticketMessage, $ticketUser)) { |
|
|
if($this->isTicketMessageUnread($ticketMessage, $ticketUser)) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
return $ticket->ticketMessages[0]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function countTicketsUnreadByUserFromArray(array $ticketsArray, User $user): int |
|
|
public function countTicketsUnreadByUserFromArray(array $ticketsArray, User $user): int |