예제 #1
0
 /**
  * Get a users post count (posts created and replies).
  * @param int $user_id User Id.
  * @return int
  */
 public function getPostCount($user_id)
 {
     /* Get count from forum posts */
     try {
         $posts = ForumPost::where('author_id', $user_id)->get();
         $posts = count($posts);
     } catch (Exception $e) {
         $posts = 0;
     }
     /* Get count from forum replies */
     try {
         $replies = ForumReply::where('author_id', $user_id)->get();
         $replies = count($replies);
     } catch (Exception $e) {
         $replies = 0;
     }
     /* Return total */
     return $posts + $replies;
 }
예제 #2
0
 private function postExists($post_id)
 {
     try {
         $post = ForumPost::where('id', $post_id)->firstOrFail();
         return $post;
     } catch (\Exception $e) {
         return false;
     }
 }