public function getShow($id) { // $id = \Input::get('id', 0); $article = BlogPost::find($id); if (is_null($article)) { return '404 not found'; } return view('blog.detail')->with('article', $article); }
/** * Ajax request to add new comment * * @param Request $request * @param $id * @return \Illuminate\Http\JsonResponse */ public function addComment(Request $request, $id) { if (Sentinel::check()) { $post = BlogPost::find($id); $comment = new Comment(); $comment->body = $request->newcomment; $user = User::find(Sentinel::check()->id); $comment->user_id = $user->id; $post->comments()->save($comment); $ajaxresponse = ['thanx' => 'Спасибо за ваш комментарий', 'userid' => $user->id, 'username' => $user->first_name, 'useravatar' => basename($user->avatar), 'newcomment' => $request->newcomment, 'datetime' => $comment->created_at->format('d.m.Y - H:i'), 'guest' => '0']; return response()->json($ajaxresponse); } else { $ajaxresponse = ['thanx' => 'Извините, гости оставлять комментарии не могут', 'guest' => '1']; return response()->json($ajaxresponse); } }