public function multidelete()
 {
     $id = Input::get('id');
     $do = new Comment();
     $list = $do->whereIn('id', $id)->delete();
     if ($list) {
         return Redirect::back()->withErrors(Null);
     } else {
         return Redirect::back()->withInput()->withErrors('comment delete fail!');
     }
 }
Example #2
0
 /**
  * Handle the event.
  *
  * @param  SingleAdLoaded  $event
  * @return void
  */
 public function handle(SingleAdLoaded $event)
 {
     $ad = $event->ad;
     $ad->increment('views');
     if ($user = Auth::user()) {
         if ($user->id == $ad->author_id) {
             $ad->comments()->where('answer_to', null)->update(['is_viewed' => true]);
         } else {
             $questions_ids = $ad->comments()->where('author_id', $user->id)->get()->map(function ($question) {
                 return $question->id;
             });
             Comment::whereIn('answer_to', $questions_ids)->update(['is_viewed' => true]);
         }
     }
 }
Example #3
0
 public function delcomment(Request $request)
 {
     $id = (array) $request->id;
     $comments = Comment::whereIn('id', $id)->get(['article_id']);
     if ($comments) {
         $articleIds = $comments->fetch('article_id');
         Comment::whereIn('id', $id)->delete();
         foreach ($articleIds as $article_id) {
             Article::withTrashed()->whereId($article_id)->decrement('comment_count');
         }
         return response()->json(200);
     } else {
         return response()->json(404);
     }
     return response()->json($articleIds);
 }
Example #4
0
 public function getSubComments()
 {
     $ids = SubComment::where('comment_id_from', '=', $this->id)->orderBy('created_at', 'DESC')->lists('comment_id_sub');
     return Comment::whereIn('id', $ids)->get();
 }