/** * Insert inner comment in DB * * @param Request $request * @param integer $messageId * @param object $reply * * @return void */ private function insertInnerComment($request, $messageId, $reply) { $innerComment = new InnerComment(); if ($this->message->where('fb_post_id', $messageId)->exists()) { $message = $this->message->where('fb_post_id', $messageId)->first(); $innerComment->message_id = $message->id; } else { $answer = $this->answer->where('fb_post_id', $messageId)->first(); $innerComment->answer_id = $answer->id; } $innerComment->user_id = Auth::user()->id; $innerComment->fb_post_id = $reply->id; $innerComment->fb_reply_id = $messageId; $innerComment->message = $request->input('answer_specific'); $innerComment->post_date = Carbon::now(); $innerComment->save(); }
private function getComments() { $collection = collect(); $messages = $this->message->where('fb_post_id', '!=', '')->get(); $answers = $this->answer->where('fb_post_id', '!=', '')->get(); $reactions = $this->reaction->where('fb_post_id', '!=', '')->get(); foreach ($messages as $key => $message) { $collection->push($message); } foreach ($answers as $key => $answer) { $collection->push($answer); } foreach ($reactions as $key => $reaction) { $collection->push($reaction); } return $collection; }
/** * Gets number answers sent today * * @return integer */ private function getTodaysMessages() { return count($this->answer->TodaysAnswers()); }
public function scopeTodaysAnswers() { return Answer::where('post_date', '>=', Carbon::today())->get(); }
/** * Inserts answer to database * * @param string $type * @param Request $request * @param object $case * @param string $message * @param string $reply * @param string $handle * * @return void */ private function insertAnswer($type, $request, $case, $message, $reply, $handle) { $answer = new Answer(); $answer->case_id = $case->id; $answer->user_id = Auth::user()->id; $answer->answer = $request->input('answer'); $answer->post_date = Carbon::now(); if (is_a($message, "Rubenwouters\\CrmLauncher\\Models\\Answer")) { $answer->answer_id = $message->id; } else { $answer->message_id = $message->id; } if ($type == self::TYPE_TWEET) { $answer->tweet_id = $reply['id_str']; if ($case->origin == 'Twitter mention') { if ($reply['in_reply_to_status_id_str'] != null) { $answer->tweet_reply_id = $reply['in_reply_to_status_id_str']; } else { $answer->tweet_reply_id = 0; } } } else { if ($type == self::TYPE_FACEBOOK_POST) { $answer->fb_post_id = $reply->id; $answer->fb_reply_id = $message->fb_post_id; } else { if ($type == self::TYPE_FACEBOOK_PRIVATE) { $answer->fb_private_id = $reply->id; $answer->fb_reply_id = $message->fb_conversation_id; } } } $answer->save(); $this->case->openCase($case); $this->linkCaseToUser($case); }