service->update($id, ['active' => true]); return $this->updated(SerializerRegistry::getInstance()->getSerializer($api)->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); } } /** * @return array */ protected function getFilterRules():array{ return [ 'resource_server_id' => ['=='] ]; } /** * @return array */ protected function getFilterValidatorRules():array{ return [ 'resource_server_id' => 'sometimes|required|integer', ]; } /** * @param $id * @return \Illuminate\Http\JsonResponse|mixed */ public function deactivate($id) { try { $api = $this->service->update($id, ['active' => false]); return $this->updated(SerializerRegistry::getInstance()->getSerializer($api)->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); } } /** * @return array */ protected function getUpdatePayloadValidationRules(): array { return [ 'name' => 'sometimes|required|alpha_dash|max:255', 'description' => 'sometimes|required|text', 'active' => 'sometimes|required|boolean', ]; } /** * @return array */ protected function getCreatePayloadValidationRules(): array { return [ 'name' => 'required|alpha_dash|max:255', 'description' => 'required|text', 'active' => 'required|boolean', 'resource_server_id' => 'required|integer', ]; } }