Code Duplication    Length = 13-14 lines in 3 locations

app/Http/Controllers/Admin/Blog/CategoryController.php 1 location

@@ 111-124 (lines=14) @@
108
     *
109
     * @return \Illuminate\Http\RedirectResponse
110
     */
111
    public function delete(int $id): RedirectResponse
112
    {
113
        $category = Category::findOrFail($id);
114
115
        if ($category->delete()) {
116
            return redirect()
117
                ->route('admin.blog.category.index')
118
                ->with('success', 'This category has been deleted successfully !');
119
        }
120
121
        return redirect()
122
            ->route('admin.blog.category.index')
123
            ->with('danger', 'An error occurred while deleting this category !');
124
    }
125
}
126

app/Http/Controllers/Admin/Blog/ArticleController.php 1 location

@@ 137-150 (lines=14) @@
134
     *
135
     * @return \Illuminate\Http\RedirectResponse
136
     */
137
    public function delete(int $id): RedirectResponse
138
    {
139
        $article = Article::findOrFail($id);
140
141
        if ($article->delete()) {
142
            return redirect()
143
                ->route('admin.blog.article.index')
144
                ->with('success', 'This article has been deleted successfully !');
145
        }
146
147
        return redirect()
148
            ->route('admin.blog.article.index')
149
            ->with('danger', 'An error occurred while deleting this article !');
150
    }
151
}
152

app/Http/Controllers/Discuss/ConversationController.php 1 location

@@ 120-132 (lines=13) @@
117
     *
118
     * @return \Illuminate\Http\RedirectResponse
119
     */
120
    public function delete(string $slug, int $id) : RedirectResponse
121
    {
122
        $conversation = DiscussConversation::findOrFail($id);
123
124
        if ($conversation->delete()) {
125
            return redirect()
126
                ->route('discuss.index')
127
                ->with('success', 'This discussion has been deleted successfully !');
128
        }
129
130
        return back()
131
            ->with('danger', 'An error occurred while deleting this discussion !');
132
    }
133
134
    /**
135
     * Get the current page for the conversation.