repository->getByIp(strval($ip)); } else { $banned_ip = $this->repository->getById(intval($id)); } if (is_null($banned_ip)) { throw new EntityNotFoundException(); } return $this->ok(SerializerRegistry::getInstance()->getSerializer($banned_ip)->serialize()); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412(array( $ex1->getMessage())); } catch (EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(array('message' => $ex2->getMessage())); } catch (Exception $ex) { Log::error($ex); return $this->error500($ex); } } /** * @param null $id * @return \Illuminate\Http\JsonResponse|mixed */ public function delete($id = null) { try { if (is_null($id)) { $ip = Input::get("ip", null); } else { $banned_ip = $this->repository->getById($id); $ip = $banned_ip->getIp(); } if (is_null($ip)) return $this->error400('invalid request'); $this->service->deleteByIP($ip); return $this->deleted(); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412(array( $ex1->getMessage())); } catch (EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(array('message' => $ex2->getMessage())); } catch (Exception $ex) { Log::error($ex); return $this->error500($ex); } } /** * @return array */ protected function getUpdatePayloadValidationRules(): array { return []; } /** * @return array */ protected function getCreatePayloadValidationRules(): array { return []; } }