public function postDelete() { Auth::getUser()->hasPermissionOr401(Config::get("permissions.apiUsers"), 1); $resp = array("success" => false); if (FormHelpers::hasPost("id")) { $id = intval($_POST["id"], 10); DB::transaction(function () use(&$id, &$resp) { $apiUser = ApiUser::find($id); if (!is_null($apiUser)) { if ($apiUser->delete() === false) { throw new Exception("Error deleting ApiUser."); } $resp['success'] = true; } }); } return Response::json($resp); }