/** * @return mixed */ public function getPosts() { $builder = Post::with('userInfo', 'category', 'images')->whereDeleted(false); return respondWithPagination(morphPage($builder)); }
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; }