示例#1
0
 public function show($id)
 {
     if (is_null($id)) {
         return view('errors.404');
     }
     $post = Post::with('user')->find($id);
     if (!$post) {
         return view('errors.404');
     }
     $comments = Comment::with('user')->where('post_id', $id)->orderBy('created_at', 'desc')->paginate(5);
     $this->viewData['post'] = $post;
     $this->viewData['comments'] = $comments;
     return view('posts.show', $this->viewData);
 }