protected function privateMessage(User $user, $forId, $data) { $message = new Message(); $message->user = $user; $message->for = User::find($forId); $message->datetime = new \DateTime(); $message->data = $data; $message->save(); $this->sendToUser($forId, Protocol::message($message)); return $message; }
/** * When we send to user private message, we need to send this message to author. * * @param \ElfChat\Entity\User $user * @param $forId * @param $data * @return Message */ protected function privateMessage(User $user, $forId, $data) { $message = parent::privateMessage($user, $forId, $data); if ($forId !== $user->id) { $this->sendToUser($user->id, Protocol::message($message)); } return $message; }