/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $comment = Comment::findOrFail($id); $comment->fill($request->all()); $comment->save(); return $comment; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $Comment = Comment::findOrFail($id); $Content = $Comment->entity; $route = route($Content->getAppointRoute('show'), $Content->id) . '#section-comment-' . $Comment->id; return redirect()->to($route); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $comment = Comment::findOrFail($id); $this->authorize('update-destroy', $comment); $comment->delete(); return $comment; }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $this->validate($request, ['content' => 'required']); Comment::findOrFail($id)->update($request->only('content')); flash()->success(trans('forum.comment_edit')); return back(); }
public function comment_delete($id) { $comment = Comment::findOrFail($id); $comment->delete(); Session::flash('comment_deleted', 'alt'); return redirect::back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $comment = Comment::findOrFail($id); if ($comment->userId == Auth::user()->id || Auth::user()->isUserAdmin()) { $comment->delete(); } return redirect(URL::previous()); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($task_id, $comment_id) { $comment = Comment::findOrFail($comment_id); if ($comment->task_id != $task_id) { abort(404); } $comment->delete(); }
/** * Vote up or down for the given comment. * * @param \Illuminate\Http\Request $request * @param $id * @return \Illuminate\Http\JsonResponse */ public function vote(Request $request, $id) { $this->validate($request, ['vote' => 'required|in:up,down']); $comment = Comment::findOrFail($id); $up = $request->input('vote') == 'up' ? true : false; $comment->votes()->create(['user_id' => $request->user()->id, 'up' => $up ? 1 : null, 'down' => $up ? null : 1]); return response()->json(['voted' => $request->input('vote'), 'value' => $comment->votes()->sum($request->input('vote'))]); }
/** * Remove the specified resource from storage. * * @param int $questionId * @param int $id * @return Response */ public function destroy($questionId, $id) { $comment = Comment::findOrFail($id); if (!$comment->canEdit()) { abort('403', 'Not authorized.'); } $comment->delete(); return redirect()->action('QuestionController@show', $questionId)->with('message', '<div class="alert alert-info">Comment deleted.</div>'); }
/** * @param $id * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function destroy($id, Request $request) { $comment = Comment::findOrFail($id); if (!$request->user()->isAdmin() || $comment->user_id != $request->user()->id) { return redirect()->home(); } $comment->delete(); return redirect()->back()->with('success', 'Comment Deleted!'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $this->validate($request, ['content' => 'required']); $comment = Comment::findOrFail($id); $comment->update($request->only('content')); event('comments.updated', [$comment]); event(new ModelChanged('comments')); flash()->success(trans('forum.comment_edit')); return back(); }
public function destroy(Request $request, $id) { $comment = Comment::findOrFail($id); $comment->delete(); $flash = ['flash_message' => 'Comment has been deleted successfully!']; if ($request->ajax()) { return response()->json($flash); } else { return redirect()->back()->with($flash); } }
/** * Execute the job. * * @return void */ public function handle() { // $comment = Comment::findOrFail($this->id); $comment->status = $this->status; if ($comment->save()) { return "success"; } else { return "failed"; } }
/** * Vote up or down for the given comment. * * @param \Illuminate\Http\Request $request * @param $id * @return \Illuminate\Http\JsonResponse */ public function vote(Request $request, $id) { $this->validate($request, ['vote' => 'required|in:up,down']); if (Vote::whereCommentId($id)->whereUserId($request->user()->id)->exists()) { return response()->json(['errors' => 'Already voted!'], 409); } $comment = Comment::findOrFail($id); $up = $request->input('vote') == 'up' ? true : false; $comment->votes()->create(['user_id' => $request->user()->id, 'up' => $up ? 1 : null, 'down' => $up ? null : 1, 'voted_at' => \Carbon\Carbon::now()->toDateTimeString()]); return response()->json(['voted' => $request->input('vote'), 'value' => $comment->votes()->sum($request->input('vote'))]); }
/** * Redirects to the comment on the questions page. * @param string $id The id of the comment. * @return Redirect */ public function show($id) { $comment = Comment::findOrFail($id); $commentable = $comment->commentable; if (get_class($commentable) === 'App\\Question') { $questionId = $commentable->id; } else { $questionId = $commentable->question->id; } $bookmark = '#comment-' . $comment->id; return redirect(route('questions.show', $questionId) . $bookmark); }
public function delete($id) { $comment = Comment::findOrFail($id); if ($comment->user_id == Auth::user()->id) { $removed = $comment; // store removed item for returning $comment->delete(); return ['status' => 'Ok', 'message' => 'Comment removed', $removed]; } else { return ['error' => ['message' => 'You can not remove not yours comment']]; } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $comment = Comment::findOrFail($id); $this->validate($request, ['comment' => 'required|max:255']); $data = $request->only('comment'); $comment->update($data); $artikel = Artikel::findOrFail($request->artikel_id); $comments = Comment::with('user')->where('artikel_id', '=', $id)->get(); Session::put('notiftype', 'success'); Session::put('notifmessage', 'comment edited succesfully.'); return back(); }
public function edit($id) { if (\Auth::guest()) { } else { $comment = Comment::findOrFail($id); if (\Auth::user()->name == $comment->name) { $comment = Comment::where('id', '=', $id)->update(array('comment' => \Request::input('editcomment'), 'id' => $id)); \Flash::success('コメントを変更しました id:' . $id); } } return Redirect::back(); }
/** * Store a newly created resource in storage. * * @param $id * @param CreateAnswerRequest $request * @return Response */ public function store($id, CreateAnswerRequest $request) { $comment = Comment::findOrFail($id); $reply = new Reply(); $reply->fill($request->all()); $reply->user_id = Auth::user()->id; $reply->comment_id = $comment->id; $reply->save(); $messages = trans('messages.replies.create'); if ($request->ajax()) { return $messages; } }
public function viewUpdate($id) { // Set logged in user to a variable. $authUser = Auth::user(); // Find comment in database. $comment = Comment::findOrFail($id); // Find the comment's user in database, set to variable. $userId = $comment->user_id; $user = User::findOrFail($userId); // If logged in user does not own photo, return error. if ($authUser->id !== $user->id) { return view('errors.403'); } // Return view with variables. return view('comments.viewUpdate')->with('comment', $comment)->with('authUser', $authUser)->with('user', $user); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { parent::boot($router); $router->bind('posts', function ($id) { return \App\Post::published()->findOrFail($id); }); $router->bind('users', function ($id) { return \App\User::findOrFail($id); }); $router->bind('roles', function ($name) { return \App\Role::where('role', $name)->firstOrFail(); }); $router->bind('comments', function ($id) { return \App\Comment::findOrFail($id); }); $router->bind('tags', function ($name) { return \App\Tag::where('name', $name)->firstOrFail(); }); }
public function cancel($group_id, $discussion_id, $comment_id) { $vote = \App\Vote::firstOrNew(['comment_id' => $comment_id, 'user_id' => auth()->user()->id]); // if the vote was 1, we can decrement the total in the comment table if ($vote->vote == 1) { $comment = \App\Comment::findOrFail($comment_id); $comment->vote--; $comment->save(); } // if the vote was -1, we can increment the total in the comment table if ($vote->vote == -1) { $comment = \App\Comment::findOrFail($comment_id); $comment->vote++; $comment->save(); } $vote->vote = 0; $vote->save(); return redirect()->back(); }
/** * Created By Dara on 8/2/2016 * add reply to comment */ public function session(Session $session, $comment_id, Request $request) { $user = $this->user; $this->validate($request, ['content' => 'required']); if ($comment_id) { //check if the comment has been set or not (reply) level 2 comment $comment = Comment::findOrFail($comment_id); $parent_id = $comment->id; $msg = trans('users.answerSent'); $nested = true; } else { //level 1 comment $parent_id = 0; $msg = trans('users.commentSent'); $nested = false; } //add comment to db $newComment = $session->comments()->create(['user_id' => $user->id, 'content' => $request->input('content'), 'parent_id' => $parent_id]); $numComment = $session->comments()->count(); $session->update(['num_comment' => $numComment]); $obj = $session; $model = 'session'; return ['hasCallback' => 1, 'callback' => 'session_comment', 'hasMsg' => 1, 'msgType' => '', 'msg' => $msg, 'returns' => ['newComment' => view('comment.comment', compact('newComment', 'session', 'user', 'obj', 'model'))->render(), 'nested' => $nested, 'numComment' => $numComment]]; }
public function delete($id) { $comment = Comment::findOrFail($id); $comment->delete(); return Redirect::to('admin/comment_operate')->withErrors(Null); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id, Request $request) { $comment = \App\Comment::findOrFail($id); $comment->delete(); if ($request->ajax()) { return response()->json(['status' => true, 'message' => '']); } }
public function edit($id) { $comment = Comment::findOrFail($id); return redirect('posts/' . $comment['post_id']); }
/** * 删除评论 * * @param integer $id * * @return Response */ public function getDelete($id) { return Comment::findOrFail($id)->delete(); }
/** * Execute the job. * * @return void */ public function handle() { // $comment = Comment::findOrFail($this->id[0]); return view('blog.cms.comment.edit', compact('comment')); }
public function massdel(Request $request) { $massdel = $request->input('massdel'); if ($massdel) { try { foreach ($massdel as $id => $value) { $roomtype = Comment::findOrFail($id); $roomtype->delete(); } } catch (NullException $e) { return redirect()->back()->with('Mess', 'Có lỗi xảy ra!'); } DB::commit(); return redirect()->back()->with('Mess', 'Đã xóa'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(Request $request, $id) { $comment = Comment::findOrFail($id); $comment->delete(); return redirect()->route('articles.show', [$request->article_id]); }