public function retrieve() { $twitterPosts = SocialPost::join('user_social_post', 'social_post.id', '=', 'user_social_post.social_post_id')->where('user_social_post.user_id', '=', $this->userId)->where('social_post.type', '=', 'twitter')->select('social_post.*')->get(); $maxId = 0; foreach ($twitterPosts as $post) { $postJSON = json_decode($post->post); $maxId = $postJSON->id > $maxId ? $postJSON->id : $maxId; } return $maxId; }
private function checkPostInDB($postId, $userId) { $instagramPostsFromUser = SocialPost::join('user_social_post', 'social_post.id', '=', 'user_social_post.social_post_id')->where('user_social_post.user_id', '=', $userId)->where('social_post.type', '=', 'instagram')->get(); foreach ($instagramPostsFromUser as $instagramPost) { $post = json_decode($instagramPost->post); if ($post->id === $postId) { return true; } } return false; }
public function retrieve() { return 0; $instagramPosts = SocialPost::join('user_social_post', 'user_social_post.social_post_id', '=', 'social_post.id')->where('social_post.type', '=', 'instagram')->where('user_social_post.user_id', '=', $this->userId)->get(); }