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


PHP Comment::find方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage. Requires a post with 'comment_id' and 'position'
  *
  * @return Response
  */
 public function store()
 {
     //Check user permissions
     if (!Auth::user()->can('create-comment_votes')) {
         abort(401, 'You do not have permission to vote on a comment');
     }
     //Check validation
     $input = Request::all();
     if (!isset($input['comment_id'])) {
         abort(422, 'comment_id is required');
     }
     //Gets the comment that is to be voted on
     $comment = Comment::find($input['comment_id']);
     //Does the fields specified as fillable in the model
     if (!$comment) {
         abort(403, 'There is no comment with the id of ' . $input['comment_id']);
     }
     //Check logged in user has voted, and on this comment's motion
     $vote = Vote::where('user_id', Auth::user()->id)->where('motion_id', $comment->motion_id)->first();
     if (!$vote) {
         abort(403, 'User must vote before posting comment');
     }
     $commentVote = new CommentVote($input);
     $commentVote->comment_id = $comment->id;
     $commentVote->vote_id = $vote->id;
     if (!$commentVote->save()) {
         abort(403, $commentVote->errors);
     }
     return $commentVote;
 }
开发者ID:dwoodard,项目名称:IserveU,代码行数:35,代码来源:CommentVoteController.php

示例2: comment

 public function comment(Request $request)
 {
     $this->validate($request, ['id' => 'required', 'type' => 'required|in:1,-1']);
     $user = Auth::user();
     $id = $request->input('id');
     $value = $request->input('type');
     $comment = Comment::find($id);
     $isLiked = $comment->likedany($user->id);
     if (!$isLiked) {
         if ($value == 1) {
             $comment->like($user->id);
             $isLiked = 1;
         } elseif ($value == -1) {
             $comment->dislike($user->id);
             $isLiked = -1;
         }
     } elseif ($isLiked == $value) {
         $comment->unlike($user->id);
         $isLiked = 0;
     } elseif ($isLiked != $value) {
         $comment->revertlike($user->id);
         if ($isLiked == 1) {
             $isLiked = -1;
         } elseif ($isLiked == -1) {
             $isLiked = 1;
         }
     }
     return ['hasCallback' => 1, 'callback' => 'comment_liked', 'hasMsg' => 0, 'msg' => '', 'msgType' => '', 'returns' => ['num_like' => $comment->num_like, 'num_dislike' => $comment->num_dislike, 'is_liked' => $isLiked]];
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:29,代码来源:LikeController.php

示例3: getEditComment

 public function getEditComment(Request $request, $id)
 {
     $comment = Comment::find($id);
     if ($comment && $comment->comment_author_id == Auth::user()->id) {
         return view('users.forms.edit_comment_form')->with('comment', $comment);
     }
 }
开发者ID:ebrimamaubeh,项目名称:utg_bantaba,代码行数:7,代码来源:CommentController.php

示例4: updateComment

 public function updateComment(Request $request, $id)
 {
     $input = Request::all();
     $comment = Comment::where('id', $id)->update(['content' => $input['content']]);
     $comments = Comment::find($id);
     return redirect(url('/form', $comments->form_id));
 }
开发者ID:BartSchop,项目名称:schoolproject,代码行数:7,代码来源:CommentController.php

示例5: destroy

 public function destroy($id)
 {
     $comment = Comment::find($id);
     $postId = $comment->post_id;
     Comment::destroy($id);
     return redirect('/posts/' . $postId);
 }
开发者ID:erzhu4,项目名称:larvelProject,代码行数:7,代码来源:CommentsController.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $comment = Comment::find($id);
     $comment->delete();
     return Redirect::to('admin/comments');
 }
开发者ID:JV-BugMaker,项目名称:shopapi,代码行数:13,代码来源:CommentsController.php

示例7: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $comment = Comment::find($id);
     if ($comment) {
         $comment->delete();
     }
     return Comment::all();
 }
开发者ID:berkayk,项目名称:react-tutorial-v1,代码行数:14,代码来源:CommentController.php

示例8: show

 public function show($id)
 {
     $comment = Comment::find($id);
     if (!$comment) {
         return Response::json(['error' => ['message' => 'Comment does not exist']], 404);
     }
     return Response::json($comment, 200);
 }
开发者ID:navdeepsingh,项目名称:laravel-angular-comments-app,代码行数:8,代码来源:CommentController.php

示例9: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $comment = Comment::find($id);
     if ($comment->user_id == 1 || $comment->user_id == \Auth::user()->id) {
         $comment->delete();
     }
     return $comment;
 }
开发者ID:uethackathon,项目名称:uethackathon2015_team13,代码行数:14,代码来源:CommentController.php

示例10: show

 public function show($id)
 {
     $comment = Comment::find($id);
     if (!$comment) {
         return $this->error("The comment with {$id} doesn't exist", 404);
     }
     return $this->success($comment, 200);
 }
开发者ID:omarelgabry,项目名称:lumen-api-oauth,代码行数:8,代码来源:CommentController.php

示例11: delete_item

 public function delete_item($c_id)
 {
     $c = Comment::find($c_id);
     $this->authorize('qna-edit', $c);
     $c->delete();
     $redirectUrl = $this->getRedirectUrlWithComment($c);
     return redirect($redirectUrl);
 }
开发者ID:smartbos,项目名称:qna,代码行数:8,代码来源:CommentController.php

示例12: postRemove

 public function postRemove($id)
 {
     $comment = Comment::find($id);
     if ($comment->user_id == Auth::user()->id) {
         $comment->delete();
     }
     return redirect()->back();
 }
开发者ID:jetcms,项目名称:website,代码行数:8,代码来源:CommentController.php

示例13: run

 public function run()
 {
     for ($j = 1; $j <= 200; $j++) {
         $user = User::find(rand(1, 10));
         $comment = Comment::find($j);
         Comment_like::create(['user_id' => $user->id, 'post_id' => $comment->id]);
     }
 }
开发者ID:sosweet-yasir,项目名称:blog,代码行数:8,代码来源:Comment_likeTableSeeder.php

示例14: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($kdThread)
 {
     //
     $comment = Comment::find($kdThread);
     //$threadforum=Threadforum::all();
     //return view('threadforum.comment.index',compact('comment'));
     return $comment->toJson();
 }
开发者ID:roardi,项目名称:ForumProject,代码行数:14,代码来源:CommentController.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $comment = \App\Comment::find($request->id);
     if ($comment->user->id == \Auth::user()->id) {
         return $next($request);
     } else {
         return redirect('home');
     }
 }
开发者ID:bbig979,项目名称:shoppyst,代码行数:16,代码来源:VerifyOwnerForComment.php


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