service->update($id, ['active' => true]); return $this->updated(SerializerRegistry::getInstance()->getSerializer($entity)->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 $id * @return \Illuminate\Http\JsonResponse|mixed */ public function deactivate($id){ try { $entity = $this->service->update($id, ['active' => false]); return $this->updated(SerializerRegistry::getInstance()->getSerializer($entity)->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' => 'required|text|max:512', 'active' => 'required|boolean', 'scopes' => 'required', 'users' => 'required|user_ids', ]; } /** * @return array */ protected function getCreatePayloadValidationRules(): array { return [ 'name' => 'required|text|max:512', 'active' => 'required|boolean', 'scopes' => 'required', 'users' => 'required|user_ids', ]; } }