/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(APIControllerHelper $helper, UpdatePaymentAddressRequest $request, PaymentAddressRepository $payment_address_respository, $id) { return $helper->update($payment_address_respository, $id, $request->only(array_keys($request->rules()))); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, UpdateAccountRequest $request, Guard $auth, AccountRepository $account_respository, APIControllerHelper $helper) { $user = $auth->getUser(); if (!$user) { throw new Exception("User not found", 1); } // get non null attributes only $attributes = $request->only(array_keys($request->rules())); $non_null_attributes = []; foreach ($attributes as $k => $v) { if ($v !== null) { $non_null_attributes[$k] = $v; } } if (!$non_null_attributes) { return $helper->buildJSONResponse(['message' => 'nothing to update'], 400); } // update try { return $helper->update($account_respository, $id, $non_null_attributes, $user); } catch (Exception $e) { if ($e->getCode() >= 400 and $e->getCode() < 500) { throw new HttpResponseException(new JsonResponse(['message' => $e->getMessage()], 400)); } throw $e; } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(APIControllerHelper $helper, UpdateMonitorRequest $request, MonitoredAddressRepository $address_respository, $id) { return $helper->update($address_respository, $id, $helper->getAttributesFromRequest($request)); }