/** * Delete an Agent by id * @param type $id * @param type Article $article * @return Response */ public function destroy($slug, Article $article, Relationship $relation, Comment $comment) { /* delete the selected article from the table */ $article = $article->where('slug', $slug)->first(); //get the selected article via id //dd($article); $id = $article->id; $comments = $comment->where('article_id', $id)->get(); if ($comments) { foreach ($comments as $comment) { $comment->delete(); } } $relation = $relation->where('article_id', $id)->first(); if ($relation) { $relation->delete(); } if ($article) { if ($article->delete()) { return Redirect::back()->with('success', 'Article Deleted Successfully'); } else { return Redirect::back()->with('fails', 'Article Not Deleted'); } } else { return Redirect::back()->with('fails', 'Article can Not Deleted'); } }