/** * 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; }
public function scopeTodaysAnswers() { return Answer::where('post_date', '>=', Carbon::today())->get(); }