コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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');
     }
 }
コード例 #4
0
 /**
  * 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);
 }
コード例 #5
0
ファイル: PostsController.php プロジェクト: BlastFire/lara
 /**
  * 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;
 }
コード例 #6
0
 /**
  * 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();
 }
コード例 #7
0
 /**
  * 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;
 }
コード例 #8
0
 /**
  * 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();
 }
コード例 #9
0
 /**
  * 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();
 }
コード例 #10
0
ファイル: PostController.php プロジェクト: jakeboyles/GuyBuy
 /**
  * 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]);
 }
コード例 #11
0
ファイル: CommentsController.php プロジェクト: anrito/video
 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();
 }
コード例 #12
0
 public function findByField($fieldName, $fieldValue, $columns = ['*'])
 {
     return Comment::with('user')->where($fieldName, $fieldValue)->orderBy('created_at', 'ASC')->get($columns);
 }
コード例 #13
0
ファイル: ApiController.php プロジェクト: gfdeveloper/LCCB
    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;
    }
コード例 #14
0
 /**
  * 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);
 }
コード例 #15
0
 public function comments()
 {
     $comments = Comment::with('article')->with('user')->orderBy('created_at', 'DESC')->paginate(10);
     return view('admin.articles.comments', compact('comments'));
 }
コード例 #16
0
 public function index()
 {
     $comments = Comment::with('post')->orderBy('created_at', 'desc')->paginate(10)->toArray();
     return view('admin.comments.index', compact('comments'));
 }
コード例 #17
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $shame = Shame::findOrFail($id);
     $parsedown = new Parsedown();
     $parsedown->setBreaksEnabled(true)->setMarkupEscaped(true);
     $shame->markdown = $parsedown->text($shame->markdown);
     $comments = Comment::with('user', 'upvotes')->where('shame_id', '=', $id)->get();
     return view('shame.show')->with(['shame' => $shame, 'comments' => $comments]);
 }
コード例 #18
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return App\Comment::with('post.user')->find($id);
 }
コード例 #19
0
ファイル: CommentController.php プロジェクト: VJan-fin/Roomie
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(RentalUnit $rentalUnit)
 {
     $comments = Comment::with('User')->where('on_rental', $rentalUnit->id)->orderBy('created_at', 'asc')->paginate(10);
     return Response::json($comments);
 }
コード例 #20
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Comment::with('parentComment', 'childComments')->findOrFail($id);
 }
コード例 #21
0
ファイル: ArticleController.php プロジェクト: misterebs/cmsku
 public function comments(Request $request)
 {
     $body = $request->body ? $request->body : '';
     $comments = Comment::with('article')->with('user')->whereBody($body)->latest()->paginate(10);
     return view('admin.articles.comments', compact('comments', 'body'));
 }
コード例 #22
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $comments = Comment::with('user')->where('user_id', '=', Auth::user()->id)->get();
     return view('comment.index')->with(['comments' => $comments]);
 }