コード例 #1
0
 public function getPost($id)
 {
     $post = Post::visible()->with(['profile'])->find($id);
     if (is_null($post)) {
         return response()->json(['error' => 'Post not found.'], 404);
     } else {
         return response()->json($post);
     }
 }
コード例 #2
0
 /**
  * Display specified post
  *
  * @param int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $post = Post::visible()->find($id);
     return view('posts.show', compact('post'));
 }