当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::findOrFail方法代码示例

本文整理汇总了PHP中app\Comment::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::findOrFail方法的具体用法?PHP Comment::findOrFail怎么用?PHP Comment::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Comment的用法示例。


在下文中一共展示了Comment::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * 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;
 }
开发者ID:moshtaghi,项目名称:ideabase,代码行数:14,代码来源:CommentController.php

示例2: show

 /**
  * 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);
 }
开发者ID:jvlstudio,项目名称:3N1WebSite,代码行数:13,代码来源:CommentController.php

示例3: destroy

 /**
  * 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;
 }
开发者ID:nickdunn2,项目名称:breddit,代码行数:13,代码来源:CommentsController.php

示例4: update

 /**
  * 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();
 }
开发者ID:gabrieljo,项目名称:l5essential,代码行数:14,代码来源:CommentsController.php

示例5: comment_delete

 public function comment_delete($id)
 {
     $comment = Comment::findOrFail($id);
     $comment->delete();
     Session::flash('comment_deleted', 'alt');
     return redirect::back();
 }
开发者ID:DarkBlackJPG,项目名称:Learn_ON-1,代码行数:7,代码来源:CoursesController.php

示例6: destroy

 /**
  * 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());
 }
开发者ID:starkbaum,项目名称:sucon,代码行数:14,代码来源:CommentsController.php

示例7: destroy

 /**
  * 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();
 }
开发者ID:BostjanOb,项目名称:ProTODO,代码行数:14,代码来源:CommentsController.php

示例8: vote

 /**
  * 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'))]);
 }
开发者ID:mwasa,项目名称:l5essential,代码行数:15,代码来源:CommentsController.php

示例9: destroy

 /**
  * 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>');
 }
开发者ID:alexpcoleman,项目名称:fitl,代码行数:16,代码来源:QuestionCommentController.php

示例10: destroy

 /**
  * @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!');
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:14,代码来源:CommentController.php

示例11: update

 /**
  * 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();
 }
开发者ID:SH4CK3RS,项目名称:l5essential,代码行数:17,代码来源:CommentsController.php

示例12: destroy

 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);
     }
 }
开发者ID:absent1706,项目名称:laravel-minihabr,代码行数:11,代码来源:CommentsController.php

示例13: handle

 /**
  * 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";
     }
 }
开发者ID:shine1rainbow,项目名称:blog,代码行数:16,代码来源:Update.php

示例14: vote

 /**
  * 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'))]);
 }
开发者ID:appkr,项目名称:l5essential,代码行数:18,代码来源:CommentsController.php

示例15: show

 /**
  * 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);
 }
开发者ID:nilstr,项目名称:stackoverflow-clone,代码行数:17,代码来源:CommentsController.php


注:本文中的app\Comment::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。