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); } }
/** * 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')); }