public function anyDetail($id) { $blogs = Blogs::find($id); $relate_blogs = Blogs::limit(3)->get(); $comments = $blogs->comments; return view("news.detail")->withBlogs($blogs)->withComments($comments)->withRelateBlog($relate_blogs); }
public function postIndex(Request $request) { if (!$request->input("id")) { return; } $rs = Blogs::find($request->input("id")); return json_encode($rs); }
public function show($id) { $rs = Blogs::find($id); if (!$rs) { echo json_encode(["blog_title" => "Not found", "blog_content" => "Not found"]); return; } $comment = Comment::where("comment_blogs_id", $id)->get(); echo json_encode(["blog_title" => $rs->blog_title, "blog_content" => $rs->blog_content]); die; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if (Blogs::find($id)->delete()) { return redirect($this->prefix_redirect . '/blogs/'); } }