public function delete($id, Request $request, Application $app) { $event = new Event($app['dbconn']); if ($event->isEventExist($id)) { $error = array("message" => "Event {$id} does not exist."); return $app->json($error, 403); } try { $result = $app['dbconn']->delete('events', array('id' => $id)); if ($result) { return $app->json(array("message" => "Event {$id} is deleted!"), 201); } else { return $app->json($issue_post, 403); } } catch (\Exception $e) { $error = array("message" => $e->getMessage()); return $app->json($error, 403); } }