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


PHP Comment::with方法代码示例

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


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

示例1: comments

 /**
  * Display all comments by User 
  *
  * @return Response
  */
 public function comments($userId)
 {
     if (!User::find($userId)) {
         throw new NotFoundHttpException('no user found');
     }
     $comments = Comment::with('post', 'post.post_author')->where('user_id', $userId)->get();
     return response()->json($comments);
 }
开发者ID:artsoroka,项目名称:shopdrobeapp,代码行数:13,代码来源:UserController.php

示例2: storeComment

 public function storeComment($itemId, Request $request)
 {
     $item = Item::with('comments.user')->findOrFail($itemId);
     $comment = new Comment(['user_id' => $request->userId, 'message' => $request->message]);
     $newComment = $item->comments()->save($comment);
     $result = Comment::with('user')->findOrFail($newComment->id);
     event(new UserPostedAComment($result));
     return $result;
 }
开发者ID:marktimbol,项目名称:sell-used-items,代码行数:9,代码来源:ItemsController.php

示例3: management

 public function management()
 {
     if (Auth::user()) {
         $comments = Comment::with('product')->get();
         $data['header'] = 'comment management';
         return view('comment.management', compact('comments'), $data);
     } else {
         return redirect('/')->with('message', 'you must login to open this page');
     }
 }
开发者ID:rereyossi,项目名称:hairstuation,代码行数:10,代码来源:CommentController.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $comment = Comment::with('announcement')->find($request->id);
     if ($comment->user_id != Auth::user()->id && Auth::user()->level->level < 4) {
         Flash::error("Vous ne disposez pas des droits suffisants pour effectuer ceci !");
         return Redirect::back();
     }
     $content = $request->content;
     $comment->update(['content' => $content]);
     Flash::success('Votre commentaire a bien été modifié !');
     return redirect('announcements/view/' . $comment->announcement->slug);
 }
开发者ID:Techraav,项目名称:PolyMusic,代码行数:18,代码来源:CommentController.php

示例5: allComments

 /**
  * Helper method for sorting all the child comments to their parent
  *
  * @return the sorted comments
  **/
 private function allComments($post_id)
 {
     $comments = Comment::with('user')->where('post_id', $post_id)->get();
     $comments_by_id = new Collection();
     foreach ($comments as $comment) {
         $comments_by_id->put($comment->id, $comment);
     }
     foreach ($comments as $key => $comment) {
         $comments_by_id->get($comment->id)->children = new Collection();
         if ($comment->parent_id != 0) {
             $comments_by_id->get($comment->parent_id)->children->push($comment);
             unset($comments[$key]);
         }
     }
     return $comments;
 }
开发者ID:BlastFire,项目名称:lara,代码行数:21,代码来源:PostsController.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param \Illuminate\Http\Request $request
  * @param  int                     $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     $comment = Comment::with('replies')->find($id);
     // Do not recursively destroy children comments.
     // Because 1. Soft delete feature was adopted,
     // and 2. it's not just pleasant for authors of children comments to being deleted by the parent author.
     if ($comment->replies->count() > 0) {
         $comment->delete();
     } else {
         $comment->forceDelete();
     }
     // $this->recursiveDestroy($comment);
     event(new ModelChanged('comments'));
     if ($request->ajax()) {
         return response()->json('', 204);
     }
     flash()->success(trans('forum.deleted'));
     return back();
 }
开发者ID:mwasa,项目名称:l5essential,代码行数:26,代码来源:CommentsController.php

示例7: index

 /**
  * Display a listing of the motion's comments, this code could almost certainly be done better
  *
  * @return Response
  */
 public function index($motion)
 {
     $comments = array();
     if (Auth::user()->can('view-comments')) {
         //A full admin who can see whatever
         $comments['agreeComments'] = Comment::with('vote.user', 'commentVotes')->where('motion_id', $motion->id)->agree()->get()->sortByDesc('commentRank')->toArray();
         $comments['disagreeComments'] = Comment::with('vote.user', 'commentVotes')->where('motion_id', $motion->id)->disagree()->get()->sortByDesc('commentRank')->toArray();
     } else {
         //Load the standard cached comments for the page
         $comments = Cache::remember('motion' . $motion->id . '_comments', Setting::get('comments.cachetime', 60), function () use($motion) {
             $comments['agreeComments'] = Comment::with('vote.user', 'commentVotes')->where('motion_id', $motion->id)->agree()->get()->sortByDesc('commentRank')->toArray();
             $comments['disagreeComments'] = Comment::with('vote.user', 'commentVotes')->where('motion_id', $motion->id)->disagree()->get()->sortByDesc('commentRank')->toArray();
             return $comments;
         });
     }
     $comments['thisUsersComment'] = Comment::where('motion_id', $motion->id)->with('vote')->where('user_id', Auth::user()->id)->first();
     $comments['thisUsersCommentVotes'] = CommentVote::where('motion_id', $motion->id)->where('user_id', Auth::user()->id)->get();
     return $comments;
 }
开发者ID:dwoodard,项目名称:IserveU,代码行数:24,代码来源:MotionCommentController.php

示例8: index

 /**
  * Display a listing of comments, be sure to hide the user_id or identifying features if this person is not logged in
  *
  * @return Response
  */
 public function index()
 {
     $input = Request::all();
     if (!isset($input['start_date'])) {
         $input['start_date'] = Carbon::today();
     }
     if (!isset($input['end_date'])) {
         $input['end_date'] = Carbon::tomorrow();
     }
     if (!isset($input['number'])) {
         $input['number'] = 1;
     }
     $validator = Validator::make($input, ['start_date' => 'date', 'end_date' => 'date', 'number' => 'integer']);
     if ($validator->fails()) {
         return $validator->errors();
     }
     $comments = Comment::with('commentvotes', 'vote')->betweenDates($input['start_date'], $input['end_date'])->get()->sortBy(function ($comment) {
         return $comment->commentvotes->count();
     });
     return $comments->sortBy('commentRank')->chunk($input['number'])->reverse();
 }
开发者ID:dwoodard,项目名称:IserveU,代码行数:26,代码来源:CommentController.php

示例9: 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);
     $this->validate($request, ['comment' => 'required|max:255']);
     $data = $request->only('comment');
     $comment->update($data);
     $artikel = Artikel::findOrFail($request->artikel_id);
     $comments = Comment::with('user')->where('artikel_id', '=', $id)->get();
     Session::put('notiftype', 'success');
     Session::put('notifmessage', 'comment edited succesfully.');
     return back();
 }
开发者ID:arnevanbavel,项目名称:web-backend-2015-2016,代码行数:19,代码来源:CommentController.php

示例10: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($community, $id)
 {
     $post = Post::with('author', 'comments.author', 'community')->where('id', $id)->get();
     $comments = Comment::with('author')->where('post_id', $id)->get();
     $community = Community::where("id", $community)->get();
     $city = City::where('id', $post[0]->city_id)->get();
     return view('posts.show', ['post' => $post, "comments" => $comments, 'community' => $community, 'city' => $city]);
 }
开发者ID:jakeboyles,项目名称:GuyBuy,代码行数:14,代码来源:PostController.php

示例11: renderComments

 public function renderComments($id, $video_id)
 {
     $id = $video_id;
     $comments = Comment::with('user', 'video', 'Replay')->where('video_id', $id)->orderBy('created_at', 'desc')->get();
     return view('comments.comments', compact('id'))->with('comments', $comments)->render();
 }
开发者ID:anrito,项目名称:video,代码行数:6,代码来源:CommentsController.php

示例12: findByField

 public function findByField($fieldName, $fieldValue, $columns = ['*'])
 {
     return Comment::with('user')->where($fieldName, $fieldValue)->orderBy('created_at', 'ASC')->get($columns);
 }
开发者ID:BinaryStudioAcademy,项目名称:reviewr,代码行数:4,代码来源:CommentRepository.php

示例13: comments

    public function comments($id)
    {
        $comments = Comment::with('Author')->where('request_id', $id)->orderBy('created_at', 'desc')->get();
        $output = '';
        foreach ($comments as $comment) {
            $output .= '
			<div class="media">
                <div class="media-body">
                    <h4 class="media-heading">' . $comment->comment . '</h4>
                    ' . $comment->author->name . ' @ ' . $comment->created_at . '
				</div>
            </div>
			';
        }
        return $output;
    }
开发者ID:gfdeveloper,项目名称:LCCB,代码行数:16,代码来源:ApiController.php

示例14: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return \App\Comment::with(['post', 'user', 'parentComment', 'childComment'])->find($id);
 }
开发者ID:ethanstenis,项目名称:breddit,代码行数:10,代码来源:CommentsController.php

示例15: comments

 public function comments()
 {
     $comments = Comment::with('article')->with('user')->orderBy('created_at', 'DESC')->paginate(10);
     return view('admin.articles.comments', compact('comments'));
 }
开发者ID:litemax,项目名称:LaravelBlog,代码行数:5,代码来源:ArticleController.php


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