| @@ 134-153 (lines=20) @@ | ||
| 131 | * |
|
| 132 | * @return \Illuminate\Http\RedirectResponse |
|
| 133 | */ |
|
| 134 | public function delete(int $id): RedirectResponse |
|
| 135 | { |
|
| 136 | $article = Article::find($id); |
|
| 137 | ||
| 138 | if (is_null($article)) { |
|
| 139 | return redirect() |
|
| 140 | ->route('admin.blog.article.index') |
|
| 141 | ->with('danger', 'This article doesn\'t exist or has already been deleted !'); |
|
| 142 | } |
|
| 143 | ||
| 144 | if ($article->delete()) { |
|
| 145 | return redirect() |
|
| 146 | ->route('admin.blog.article.index') |
|
| 147 | ->with('success', 'This article has been deleted successfully !'); |
|
| 148 | } |
|
| 149 | ||
| 150 | return redirect() |
|
| 151 | ->route('admin.blog.article.index') |
|
| 152 | ->with('danger', 'An error occurred while deleting this article !'); |
|
| 153 | } |
|
| 154 | } |
|
| 155 | ||
| @@ 127-146 (lines=20) @@ | ||
| 124 | * |
|
| 125 | * @return \Illuminate\Http\RedirectResponse |
|
| 126 | */ |
|
| 127 | public function delete(int $id): RedirectResponse |
|
| 128 | { |
|
| 129 | $category = Category::find($id); |
|
| 130 | ||
| 131 | if (is_null($category)) { |
|
| 132 | return redirect() |
|
| 133 | ->route('admin.blog.category.index') |
|
| 134 | ->with('danger', 'This category doesn\'t exist or has already been deleted !'); |
|
| 135 | } |
|
| 136 | ||
| 137 | if ($category->delete()) { |
|
| 138 | return redirect() |
|
| 139 | ->route('admin.blog.category.index') |
|
| 140 | ->with('success', 'This category has been deleted successfully !'); |
|
| 141 | } |
|
| 142 | ||
| 143 | return redirect() |
|
| 144 | ->route('admin.blog.category.index') |
|
| 145 | ->with('danger', 'An error occurred while deleting this category !'); |
|
| 146 | } |
|
| 147 | } |
|
| 148 | ||