/** * Delete * * @param $section * @param $id * @throws Exception * * @return string */ public function delete($section, $id) { try { if ($section == 'image') { $fileService = new ApiFileService(null, null); $fileService->handleImageDelete($id); } else { $model = $this->setClass($section); $model->findOrFail($id)->delete(); } } catch (Exception $e) { if (gettype($e->getCode()) == 'string' || $e->getCode() == 0) { throw new \Exception($e->getMessage(), 400); } throw new Exception($e->getMessage(), $e->getCode()); } return $section . ' with id ' . $id . ' deleted'; }