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


PHP Article::comments方法代码示例

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


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

示例1: article

 public function article(Request $request, Article $article)
 {
     $user = Auth::user();
     $comment = $article->comments()->create(['user_id' => $user->id, 'body' => $request->input('body')]);
     $article->update(['num_comment' => $article->comments()->count()]);
     $this->stream($comment);
     Flash::success(trans('message.articleCommentAdded'));
     return redirect()->back();
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:9,代码来源:CommentController.php

示例2: includeComments

 /**
  * Include comments.
  *
  * @param  \App\Article                  $article
  * @param  \League\Fractal\ParamBag|null $params
  * @return  \League\Fractal\Resource\Collection
  * @throws  \Exception
  */
 public function includeComments(Article $article, ParamBag $params = null)
 {
     $transformer = new \App\Transformers\CommentTransformer($params);
     $parsed = $this->getParsedParams();
     $comments = $article->comments()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get();
     return $this->collection($comments, $transformer);
 }
开发者ID:linuxssm,项目名称:l5essential,代码行数:15,代码来源:ArticleTransformer.php

示例3: createTestStub

 /**
  * Stubbing test data.
  *
  * @param array $overrides
  */
 protected function createTestStub($overrides = [])
 {
     $this->user = !empty($overrides) ? factory(User::class)->create() : factory(User::class)->create($overrides);
     $this->user->attachRole(Role::find(2));
     $this->article = factory(Article::class)->create(['title' => 'title', 'author_id' => $this->user->id, 'content' => 'description']);
     $this->article->comments()->save(factory(Comment::class)->make(['author_id' => $this->user->id]));
     $this->article->tags()->attach(1);
     $this->article->attachments()->save(factory(Attachment::class)->make());
 }
开发者ID:pokev25,项目名称:l5essential,代码行数:14,代码来源:AuthTest.php

示例4: article

 /**
  * Created By Dara on 8/2/2016
  * add reply to comment
  */
 public function article(Article $article, $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 = $article->comments()->create(['user_id' => $user->id, 'content' => $request->input('content'), 'parent_id' => $parent_id]);
     $numComment = $article->comments()->count();
     $article->update(['num_comment' => $numComment]);
     $obj = $article;
     $model = 'article';
     return ['hasCallback' => 1, 'callback' => 'article_comment', 'hasMsg' => 1, 'msgType' => '', 'msg' => $msg, 'returns' => ['newComment' => view('comment.comment', compact('newComment', 'article', 'user', 'obj', 'model'))->render(), 'nested' => $nested, 'numComment' => $numComment]];
 }
开发者ID:emadmrz,项目名称:tinker,代码行数:28,代码来源:Commentcontroller.php

示例5: show

 /**
  * @param $id
  * @return \Illuminate\View\View
  */
 public function show(Article $article)
 {
     //$article = Article::findOrFail($id);
     //dd($article);
     /*        if (is_null($article)){
                 abort(404);
             }else {
     
             }*/
     $comments = $article->comments()->latest('published_At')->get();
     $uploadArray = $this->getUploadedContent($article);
     $upload_content = $uploadArray[0];
     $upload_type = $uploadArray[1];
     // set content-type
     //$img->header('Content-Type', 'image/jpg');
     //dd($base64);
     return view('articles.show', compact('article', 'comments', 'upload_content', 'upload_type'));
 }
开发者ID:gaofan1234,项目名称:BlogProject.dev,代码行数:22,代码来源:ArticlesController.php

示例6: show

 public function show(Article $article)
 {
     $comments = $article->comments()->with('user')->recent()->simplePaginate(10);
     $article->increment('view_count');
     return view('articles.show', compact('article', 'comments'));
 }
开发者ID:litemax,项目名称:LaravelBlog,代码行数:6,代码来源:ArticleController.php

示例7: addComment

 public function addComment(Article $article, Request $request)
 {
     $validator = Validator::make($request->all(), ['content' => 'required']);
     if ($validator->passes()) {
         // TBD check user has write access to group
         $comment = $article->comments()->create(['content' => $request->content, 'postable_type' => 'App\\Article', 'postable_id' => $article->id, 'user_id' => Auth::user()->id]);
         if ($comment) {
             return $this->respondWithItem($article, new ArticleTransformer());
         }
     } else {
         return $this->errorValidation($validator->messages);
     }
 }
开发者ID:jasonb8293,项目名称:fox-api,代码行数:13,代码来源:ArticleController.php

示例8: addReply

 public function addReply(Article $b)
 {
     $parent = Comment::find(2);
     $comment = new Comment();
     $comment->body = 'MY DICK!';
     $comment->user_id = '1';
     $b->comments()->save($comment);
     $comment->makeChildOf($parent);
     Cache::tags('commentRoot-article-' . $b->id)->flush();
     Clockwork::info('Cleared cache:' . 'commentRoot-article-' . $b->id);
     Cache::forget('commentTree-' . $comment->getRoot()->id);
     Clockwork::info('Cleared cache: ' . 'commentTree-' . $comment->getRoot()->id);
     return $comment->getRoot()->id;
 }
开发者ID:Jako81624,项目名称:GameReviewSite,代码行数:14,代码来源:ArticleController.php

示例9: includeComments

 /**
  * Include comments.
  *
  * @param  \App\Article                  $article
  * @param  \League\Fractal\ParamBag|null $params
  * @return  \League\Fractal\Resource\Collection
  * @throws  \Exception
  */
 public function includeComments(Article $article, ParamBag $params = null)
 {
     list($limit, $offset, $orderCol, $orderBy) = $this->calculateParams($params);
     $comments = $article->comments()->limit($limit)->offset($offset)->orderBy($orderCol, $orderBy)->get();
     return $this->collection($comments, new \App\Transformers\CommentTransformer());
 }
开发者ID:hongpyo,项目名称:l5essential,代码行数:14,代码来源:ArticleTransformer.php

示例10: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Article $article, Comment $comment)
 {
     // $article->comments()->where('id', $comment->id)->delete();
     $article->comments()->delete();
     Session::flash('success', 'Comment deleted');
     return Redirect::route('articles.show', $article->id);
 }
开发者ID:Vylest,项目名称:laravel-demo,代码行数:13,代码来源:CommentsController.php


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