public function postEditComment(CreateCommentRequest $request, $id) { try { $comment = Comment::findOrFail($id); // asume the use always has a profile. $profile_image_name = Profile::whereUserId($request->user()->id)->pluck('profile_image_name'); if ($comment && $comment->comment_author_id == Auth::user()->id) { $comment->body = $request->get('body'); $comment->updated_at = Carbon::now(); $comment->save(); return response()->json(array('message' => 'Your Comment has been updated', 'status' => 'success', 'body' => $comment->body, 'user_id' => Auth::id(), 'profile_image_name' => $profile_image_name, 'comment_id' => $comment->id, 'nickname' => $request->user()->nickname, 'comment_author_id' => $comment->comment_author_id)); } } catch (ModelNotFoundException $e) { return response()->json(array('message' => 'Unauthorized attempt to update comment', 'status' => 'failed')); } }