/**
  * Insert inner comment in DB
  * @param  integer $id
  * @param  Request $request
  * @param  integer $messageId
  * @param  object $reply
  * @return void
  */
 private function insertInnerComment($id, $request, $messageId, $reply)
 {
     $innerComment = new InnerComment();
     if ($this->reaction->where('fb_post_id', $messageId)->exists()) {
         $innerComment->reaction_id = $this->reaction->where('fb_post_id', $messageId)->first()->id;
     }
     $innerComment->user_id = Auth::user()->id;
     $innerComment->fb_post_id = $reply->id;
     $innerComment->fb_reply_id = $messageId;
     $innerComment->message = $request->input('answer');
     $innerComment->post_date = Carbon::now();
     $innerComment->save();
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
/**
 * Get latest comment date (Facebook)
 * @return datetime
 */
function latestCommentDate()
{
    $messageId = $reactionId = false;
    if (Message::where('fb_reply_id', '!=', '')->exists()) {
        $messageId = Message::where('fb_reply_id', '!=', '')->orderBy('post_date', 'DESC')->first()->post_date;
    }
    if (Reaction::where('fb_post_id', '!=', '')->exists()) {
        $reactionId = Reaction::where('fb_post_id', '!=', '')->orderBy('post_date', 'DESC')->first()->post_date;
    }
    return max($messageId, $reactionId);
}