Ejemplo n.º 1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function remove($id)
 {
     if (Auth::check()) {
         $comment = Comment::whereId($id)->first();
         if ($comment === null) {
             $ad_id = Request::input('ad');
         } else {
             $ad_id = $comment->ad_id;
             $user_id = Auth::user()->id;
             if ($user_id == $comment->author_id || $user_id == $comment->ad->author->id) {
                 $comment->delete();
             }
         }
         return view('sub.comments', ['ad' => Ad::getById($ad_id), 'comments' => Comment::getByAdId($ad_id)]);
     }
 }