diff --git a/Controllers/PostsController.php b/Controllers/PostsController.php index a4936ea..89546d0 100644 --- a/Controllers/PostsController.php +++ b/Controllers/PostsController.php @@ -32,7 +32,14 @@ public function action_create() { } public function action_edit() { } - public function action_delete() { + public function action_delete($id = null) { + try { + Post::find($id)->delete(); + Flash::success('The post was sucessfully deleted'); + Router::redirect('posts'); + } catch(Exception $ex) { + Router::redirect('posts', 'show', Array($id)); + } } }