예제 #1
0
 function post($id)
 {
     $data['post'] = Post::find($id);
     $data['comments'] = Comment::where('post_id', '=', $id)->with('user')->get();
     //$data['comments'] = Comment::find($id);
     return view('blog/post', $data);
 }
예제 #2
0
 /**
  * Display the specified resource.
  *
  * @param $guildSlug
  * @param $occurrenceId
  * @return \Illuminate\Http\Response
  */
 public function show($guildSlug, $occurrenceId)
 {
     $guild = Guild::where('slug', $guildSlug)->firstOrFail();
     $occurrence = EventOccurrence::with(['event', 'event.guild'])->whereHas('event.guild', function ($query) use($guild) {
         $query->where('id', $guild->id);
     })->findOrFail($occurrenceId);
     $event = $occurrence->event;
     $guild = $event->guild;
     $signups = Signup::where(['event_occurrence_id' => $occurrence->id])->orderBy('created_at')->get();
     $comments = Comment::where(['event_occurrence_id' => $occurrence->id])->orderBy('created_at')->get();
     $character = Character::whereHas('guilds', function ($query) use($guild) {
         $query->where('guilds.id', $guild->id);
     })->where(['user_id' => Auth::user()->id])->firstOrFail();
     $ownSignup = null;
     $isSigned = false;
     foreach ($signups as $signup) {
         if ($signup->character_id == $character->id) {
             $ownSignup = $signup;
             $isSigned = true;
         }
     }
     if ($ownSignup == null) {
         $ownSignup = new Signup();
     }
     $statistic = new \stdClass();
     foreach (['YES', 'MAYBE', 'NO'] as $status) {
         $name = strtolower($status);
         $statistic->{$name} = $signups->filter(function ($signup) use($status) {
             return $signup->status == $status;
         })->count();
     }
     return view('guilds.events.show', compact('occurrence', 'event', 'guild', 'signups', 'comments', 'ownSignup', 'isSigned', 'statistic'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     //$comments = DB::table('comments')->where('page_id', $id)->get();
     $comments = Comment::where('page_id', $id)->get();
     return view('admin.comments.show', ['comments' => $comments]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $task = Task::findOrFail($id);
     $comments = Comment::where('tasks_id', '=', $id)->get();
     return view('tasks.show', array('task' => $task, 'comments' => $comments));
     //
 }
 public function index(Comment $commentsModel)
 {
     //        $comments = $commentsModel->getPublishedComments();
     $comments = Comment::where('active', '=', 1)->where('published_at', '<=', Carbon::now())->latest('published_at')->simplePaginate(4);
     $comments->setPath('comments')->currentPage();
     return view('comments.comments')->with('comments', $comments);
 }
 public function show($intelligenceSlug, $tutorialId)
 {
     $intelligence = Intelligence::where('slug', $intelligenceSlug)->firstOrFail();
     $tutorial = Tutorial::where('intelligence_id', $intelligence->id)->findOrFail($tutorialId);
     $comments = Comment::where('tutorial_id', $tutorial->id)->paginate(15);
     return view('intelligence.tutorial.show', compact('intelligence', 'tutorial', 'comments'));
 }
예제 #7
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($kdThread)
 {
     //
     $comment = Comment::where('kdThread', '=', $kdThread)->with('threadforum.student', 'threadforum.lecturer', 'student', 'lecturer')->get();
     return view('threadforum.comment.index', compact('comment'));
     // return $comment->toJson();
 }
예제 #8
0
 /**
  * Shows the specific user.
  * @param string $username
  * @return Response
  */
 public function show($username)
 {
     $post_upvotes = 0;
     $user = User::where('username', '=', $username)->firstOrFail();
     $user_posts = Post::where('user_id', '=', $user->id)->take(3)->get();
     foreach ($user_posts as $post) {
         $post->username = $user->username;
         $post->comment_count = Comment::where('post_id', '=', $post->id)->count();
         $post->hub_name = Hub::where('id', '=', $post->hub_id)->firstOrFail()->name;
         $post_upvotes = $post_upvotes + (int) $post->upvotes;
         $hub = Hub::find($post->hub_id);
         if (in_array($post->user_id, explode(',', $hub->moderators))) {
             $post->user_is_mod = true;
         } else {
             $post->user_is_mod = false;
         }
         $user = User::find($post->user_id);
         if ($user->is_admin) {
             $post->user_is_admin = true;
         } else {
             $post->user_is_admin = false;
         }
     }
     $comment_upvotes = 0;
     $user_comments = Comment::where('user_id', '=', $user->id)->take(3)->get();
     foreach ($user_comments as $comment) {
         $comment_upvotes = $comment_upvotes + (int) $comment->upvotes;
         $comment->email = md5($user->email);
     }
     return view('user.show', ['user' => $user, 'email' => md5($user->email), 'post_upvotes' => $post_upvotes, 'comment_upvotes' => $comment_upvotes, 'comments' => $user_comments, 'posts' => $user_posts]);
 }
예제 #9
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function showProfile($id)
 {
     $user = User::find($id);
     $posts = Post::where("user_id", $id)->get();
     $comments = Comment::where('user_id', $id)->get();
     return view('user.profile', ['user' => $user, 'comments' => $comments, 'posts' => $posts]);
 }
예제 #10
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $adventure = Adventure::find($id);
     $comments = Comment::where('adventure_id', $id)->get();
     $pictures = Picture::where('adventure_id', $id)->get();
     return view('adventures.show', compact('adventure', 'comments'))->with('pictures', $pictures);
 }
예제 #11
0
 public function showpost($id)
 {
     //display one post
     $article = Article::findOrFail($id);
     $comment = Comment::where('postid', '=', $id)->get();
     //if (is_null($article)) {  abort(404); }
     return view('articles.show', compact('article', 'comment'));
 }
예제 #12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pre_page = 6;
     $comments = Comment::where('status', '<>', 2)->paginate($pre_page);
     //return view('admin/article/index');
     $comments->setPath('comment');
     return view('admin/comment/index')->with('comments', $comments);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $commentid
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $commentid)
 {
     $reply = new \App\Reply();
     $reply->create(['user_id' => \Auth::user()->id, 'comment_id' => $request['comment_id'], 'comment' => $request['comment']]);
     $comment = \App\Comment::where(['id' => $commentid])->get()->first();
     $comment->reply = $reply;
     return redirect()->back();
 }
예제 #14
0
파일: Comment.php 프로젝트: elberd/maoh
 public static function getByAdId($id)
 {
     $comments = Comment::where(['ad_id' => $id, 'answer_to' => null])->join('users', 'comments.author_id', '=', 'users.id')->select(['comments.*', 'users.name as author_name'])->orderBy('comments.created_at')->get();
     foreach ($comments as $comment) {
         $comment->answers = Comment::where('answer_to', $comment->id)->join('users', 'comments.author_id', '=', 'users.id')->select(['comments.*', 'users.name as author_name'])->get();
     }
     return $comments;
 }
예제 #15
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $course = Course::where('id', $id)->orWhere('slug', $id)->firstOrFail();
     $data = Data::where('courseId', $course->id)->where('extension', '!=', 'mp4')->accepted()->get();
     $videos = Data::where('courseId', $course->id)->Where('extension', 'mp4')->accepted()->get();
     $comments = Comment::where('courseId', $course->id)->get();
     return view('courses.show', compact('course', 'comments', 'data', 'videos'));
 }
예제 #16
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $article = Article::find($id);
     // get all comments for this article
     // pass allComments varialbe to view
     $allcomments = Comment::where('article_id', $article->id)->get();
     return view('articleviews.show', compact('article', 'allcomments'));
 }
 public function delete()
 {
     $usr_id = Auth::user()->id;
     if (User::destroy($usr_id)) {
         Thread::where('user_id', '=', $usr_id)->delete();
         Relation::where('user_id', '=', $usr_id)->delete();
         Comment::where('user_id', '=', $usr_id)->delete();
     }
 }
예제 #18
0
 public static function countComments($id)
 {
     $comments = \App\Comment::where('id_location', '=', $id);
     $location = Location::find($id);
     $location->rating = ceil($comments->avg('rating') / 0.5) * 0.5;
     $location->voters = $comments->count();
     $location->save();
     return $avgRating;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $comment = Comment::find($id);
     Comment::destroy($id);
     if (Comment::where('author', $comment->author)->count() < 1) {
         User::where('author', $comment->author)->delete();
     }
     return response()->json(['success' => true]);
 }
 public function DeleteComment($id)
 {
     $user = User::findOrFail(Auth::user()->id);
     if (Comment::where('id', '=', $id)->where('user_id', '=', $user->id)->delete()) {
         return Response::json(['response' => true]);
     } else {
         return Response::json(['response' => false]);
     }
 }
예제 #21
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['nickname' => 'required', 'content' => 'required']);
     if (Comment::where('id', $id)->update(Input::except(['_method', '_token']))) {
         return Redirect::to('admin/comments');
     } else {
         return Redirect::back()->withInput()->withErrors('更新失败!');
     }
 }
예제 #22
0
 public function deleteArticle($id)
 {
     $articles = Article::find($id);
     $articles->delete();
     $comment = Comment::where('article', $id);
     $comment->delete();
     //On supprimer les commentaires lié a cet article
     return redirect()->route('articles');
 }
예제 #23
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $post = new Post();
     $comment = new Comment();
     $post = Post::find($id);
     //return view('frontend.blogview',compact('post'));
     $comment = Comment::where('post_id', $id)->get();
     // $comment=Comment::find($id);
     return view('frontend.blogview', compact('post', 'comment'));
 }
예제 #24
0
 public function getComments(Request $request, Moment $moment)
 {
     $check_result = $this->requestCheck($request, ['user_id' => 'required']);
     if (!$check_result['result']) {
         return $this->response->error($check_result['message'], 422);
     }
     $payload = $request->all();
     $comments = Comment::where('moment_id', $moment->id)->orderBy('created_at', 'asc')->paginate(20);
     return $this->paginator($comments, new CommentTransformer($payload['user_id']));
 }
 public function deleteThreadById($id)
 {
     $user = User::findOrFail(Auth::user()->id);
     if (Thread::where('id', '=', $id)->where('user_id', '=', $user->id)->delete()) {
         Relation::where('thread_id', '=', $id)->delete();
         Comment::where('thread_id', '=', $id)->delete();
         return Response::json(['response' => true]);
     } else {
         return Response::json(['response' => false]);
     }
 }
예제 #26
0
 public function showDetailDocument($id)
 {
     $user = Auth::user();
     $document = Document::where(['id' => $id])->first();
     $comments = Comment::where('document_id', $id);
     $comments = $comments->join('users', 'users.id', '=', 'boss_id');
     $comments = $comments->select('comments.*', 'users.name as username');
     $comments = $comments->orderBy('updated_at', 'desc');
     $comments = $comments->get();
     return view('document/detail', ['document' => $document, 'user' => $user, 'comments' => $comments]);
 }
예제 #27
0
 public function actionDelete($id)
 {
     // Set logged in user to a variable.
     $authUser = Auth::user();
     // Find comment in database.
     $comment = Comment::where('user_id', '=', $authUser->id)->findOrFail($id);
     // Delete comment from database.
     $comment->delete($comment);
     // Redirect with flash message.
     \Session::flash('flash_message', 'You have successfully deleted your comment.');
     return redirect('/photos');
 }
예제 #28
0
 public function delComment(Request $request, $slug, $id)
 {
     $user = User::where('id', $request->user()->id)->first();
     $post = Post::where('slug', $slug)->first();
     $destroy = Comment::where('id', $id)->first();
     if ($user && $post && $destroy && $post->id == $destroy->post_id && ($user->id == $destroy->user_id || $request->user()->is_admin())) {
         $destroy->deleted_at = new Carbon();
         $destroy->save();
         return redirect()->back()->withMessage('Комментарий удален.');
     } else {
         return redirect()->route('home')->withError('Ошибка, свяжитесь с администратором.');
     }
 }
 public function show($post_id)
 {
     if (Request::ajax()) {
         //$comments = Comment::where('post_id', '=', $post_id)->where('parent_id', '=', null)->get();
         //$count = Comment::findorFail(0)->childrens;
         //return $comments;
         /*public function hasNoParent ()
                     {
         
                     }*/
         /*$comments->children;
           $user_info =
           $comments['name'] = $user_info->name;*/
         /*function find_parent ($tmp, $cur_id){
               if($tmp[$cur_id][0]['parent_id']!=0){
                   return find_parent($tmp,$tmp[$cur_id][0]['parent_id']);
               }
               return (int)$tmp[$cur_id][0]['id'];
           }*/
         //$result = '';
         function build_tree($comments)
         {
             if ($comments) {
                 $result = "<ul>\n";
                 foreach ($comments as $comment) {
                     $result .= "<li>";
                     $result .= $comment->id;
                     $result .= "</li>\n";
                     //                    $count = Comment::findorFail(2)->childrens;
                     $children = Comment::findorFail($comment->id)->childrens;
                     if (isset($children)) {
                         $result .= build_tree($children);
                     }
                     $result .= "</li>\n";
                 }
                 $result .= "</ul>";
                 return $result;
             }
         }
         $noparents = Comment::where('post_id', '=', $post_id)->where('parent_id', '=', null)->get();
         //$treepart ='';
         /*foreach ($noparents as $noparent) {
         
                         return build_tree($noparent);
         
                     }*/
         return build_tree($noparents);
         //            return $comments;
     }
     return 'Is not an AJAX Request';
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = ['Jill' => ['great'], 'Jamal' => ['bad'], 'Jon macleod' => ['good']];
     foreach ($users as $name => $comment) {
         # First get the user
         $user = \App\User::where('name', 'like', $name)->first();
         # Now loop through each comment for this user, adding the pivot
         foreach ($comment as $commentName) {
             $comment = \App\Comment::where('comment', 'LIKE', $commentName)->first();
             # Connect this comment to this user
             $user->comments()->save($comment);
         }
     }
 }