public function update(RegisterUserCategoriesRequest $request, $id) { try { $idcategories = $request->input('categories_id'); $idCategory = explode("-", $idcategories); UserCategories::whereUsersId($this->_identity->id)->delete(); foreach ($idCategory as $value) { $data['users_id'] = (int) $this->_identity->id; $data['pu_categories_id'] = (int) $value; UserCategories::create($data); } $this->_responseWS->setDataResponse(Response::HTTP_OK, [], [], 'ok'); } catch (\Exception $exc) { $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, array(), array(), ''); } $this->_responseWS->response(); }