ticketUserRepository = $this->loadService(TicketUserRepository::class); } public function instanciateTicketUser(Ticket $ticket, User $user): TicketUser { $ticketUser = new TicketUser(); $ticketUser->populateTicket($ticket); $ticketUser->populateUser($user); return $ticketUser; } public function createTicketUser(Ticket $ticket, User $user): TicketUser { $ticketUser = $this->instanciateTicketUser($ticket, $user); $this->saveCreate($ticketUser); return $ticketUser; } public function createTicketUserIfNotExist(Ticket $ticket, User $user): TicketUser { return $this->ticketUserRepository->findOneTicketUser($ticket, $user) ?? $this->createTicketUser($ticket, $user); } public function updateTicketUserReadAt(TicketUser $ticketUser) { $ticketUser->read_at = date('Y-m-d H:i:s'); $this->saveUpdate($ticketUser); } }