public function postDeleteMail(Request $request) { $this->validate($request, ['userId' => 'required', 'address' => 'required']); $address = $request->get('address'); $mail = $this->handler->emails()->findByAddress($address); if ($mail === null) { throw new EmailNotFoundException(); } XeDB::beginTransaction(); try { $this->handler->emails()->delete($mail); } catch (Exception $e) { XeDB::rollBack(); throw $e; } XeDB::commit(); return XePresenter::makeApi(['type' => 'success', 'address' => $address]); }