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


PHP Post::comments方法代码示例

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


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

示例1: store

 public function store(Request $request, Post $post)
 {
     $comment = Comment::create($request->all());
     $post->comments()->save($comment);
     Score::create(['user_id' => Auth::user()->id, 'reference' => 'comment', 'score' => 2]);
     Auth::user()->increment('scores', 2);
     return redirect()->to('posts/' . $post->slug);
 }
开发者ID:enhive,项目名称:vev,代码行数:8,代码来源:CommentController.php

示例2: getComments

 public function getComments(Post $post)
 {
     $comments = $post->comments()->getResults()->groupBy('parent_id');
     $rootComments = $comments->get(null)->groupBy('id');
     $filterOutKeys = array('');
     $filteredArr = array_diff_key($comments->toArray(), array_flip($filterOutKeys));
     return ['root_comments' => $rootComments, 'child_comments' => $filteredArr];
 }
开发者ID:khaled-barca,项目名称:MyTunnelVision,代码行数:8,代码来源:PostController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\Comment $request, Post $post)
 {
     $comment = new Comment($request->all());
     $post->comments()->save($comment);
     return redirect($post->slug);
 }
开发者ID:shempignon,项目名称:laravel-5-blog-mvc,代码行数:12,代码来源:CommentController.php

示例4: postGroupDelete

 public function postGroupDelete(Request $request, Post $post, Comment $comment)
 {
     if ($request->user()->cannot('delete-problem-comment', [$post, $comment])) {
         return ['hasCallback' => 0, 'callback' => '', 'hasMsg' => 1, 'msg' => 'شما مجوز حذف این پست را ندارید.', 'msgType' => 'danger', 'returns' => ['num_comments' => '']];
     }
     $comment->delete();
     $num_comments = $post->comments()->count();
     $post->update(['num_comment' => $num_comments]);
     return ['hasCallback' => 1, 'callback' => 'post_comment_delete', 'hasMsg' => 0, 'msg' => '', 'msgType' => '', 'returns' => ['num_comments' => $num_comments]];
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:10,代码来源:CommentController.php


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