コード例 #1
0
 /**
  * Checks if number of todays messages are greater than max
  * @return boolean [description]
  */
 public function isAboveMax()
 {
     if ($this->message->where('post_date', '>', Carbon::today())->count() > config('crm-launcher.notification.crm_notify_from_messages')) {
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: Message.php プロジェクト: rubenwouters/crm-launcher
 public function getNewestMessageDate()
 {
     if (Message::where('fb_private_id', '!=', '')->exists()) {
         return Message::where('fb_private_id', '!=', '')->orderBy('post_date', 'DESC')->first()->post_date;
     }
     return 0;
 }
コード例 #3
0
 /**
  * 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();
 }
コード例 #4
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;
 }
コード例 #5
0
ファイル: helpers.php プロジェクト: rubenwouters/crm-launcher
/**
 * 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);
}