| @@ 223-247 (lines=25) @@ | ||
| 220 | * @param int $id |
|
| 221 | * @return Redirect |
|
| 222 | */ |
|
| 223 | public function getDelete($id = null) |
|
| 224 | {
|
|
| 225 | // Get category information |
|
| 226 | $cat = Blog::getCategoriesRepository()->find($id); |
|
| 227 | ||
| 228 | if ($cat == null) |
|
| 229 | {
|
|
| 230 | // Prepare the error message |
|
| 231 | $error = Lang::get('blog.category.not_found');
|
|
| 232 | ||
| 233 | // Redirect to the category management page |
|
| 234 | return Redirect::route('categories')->with('error', $error);
|
|
| 235 | } |
|
| 236 | ||
| 237 | Base::Log('Category (' . $cat->name . ') was deleted.');
|
|
| 238 | ||
| 239 | // Delete the category |
|
| 240 | $cat->delete(); |
|
| 241 | ||
| 242 | // Prepare the success message |
|
| 243 | $success = Lang::get('blog.category.deleted');
|
|
| 244 | ||
| 245 | // Redirect to the category management page |
|
| 246 | return Redirect::route('categories')->with('success', $success);
|
|
| 247 | } |
|
| 248 | ||
| 249 | /** |
|
| 250 | * Show a list of all the deleted categories. |
|
| @@ 269-293 (lines=25) @@ | ||
| 266 | * @param int $id |
|
| 267 | * @return Redirect |
|
| 268 | */ |
|
| 269 | public function getRestore($id = null) |
|
| 270 | {
|
|
| 271 | // Get category information |
|
| 272 | $cat = Blog::getCategoriesRepository()->withTrashed()->find($id); |
|
| 273 | ||
| 274 | if ($cat == null) |
|
| 275 | {
|
|
| 276 | // Prepare the error message |
|
| 277 | $error = Lang::get('blog.category.not_found');
|
|
| 278 | ||
| 279 | // Redirect to the category management page |
|
| 280 | return Redirect::route('category.deleted')->with('error', $error);
|
|
| 281 | } |
|
| 282 | ||
| 283 | Base::Log('Category (' . $cat->name . ') was restored.');
|
|
| 284 | ||
| 285 | // Restore the category |
|
| 286 | $cat->restore(); |
|
| 287 | ||
| 288 | // Prepare the success message |
|
| 289 | $success = Lang::get('blog.category.restored');
|
|
| 290 | ||
| 291 | // Redirect to the category management page |
|
| 292 | return Redirect::route('categories.deleted')->with('success', $success);
|
|
| 293 | } |
|
| 294 | ||
| 295 | } |
|
| 296 | ||