예제 #1
0
 /**
  * @return mixed
  */
 public function getPosts()
 {
     $builder = Post::with('userInfo', 'category', 'images')->whereDeleted(false);
     return respondWithPagination(morphPage($builder));
 }
예제 #2
0
 public function getPost($postId)
 {
     $post = Post::with('userInfo', 'category', 'images')->findOrFail($postId);
     if ($post->status == Status::DISABLED) {
         throw new ResourceDisabledException();
     }
     if ($post->deleted) {
         throw new ResourceDisabledException();
     }
     $post->increment('count_views');
     return $post;
 }