當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。