/** * Updates a seller contact. * * @param int $seller_id Seller ID. * @param int $id Contact ID. * * @return void */ public function put_index($seller_id = null, $id = null) { $contact = $this->get_contact($id); $validator = \Validation_Contact::update('seller'); if (!$validator->run(\Input::put())) { throw new HttpBadRequestException($validator->errors()); } $data = $validator->validated(); $contact = \Service_Contact::update($contact, $data); if (!$contact) { throw new HttpServerErrorException(); } $this->response($contact); }
/** * POST Edit action. * * @param int $id Contact ID. * * @return void */ public function post_edit($id = null) { $this->get_edit($id); $validator = Validation_Contact::update(); if (!$validator->run()) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } $contact = $this->get_contact($id); $data = $validator->validated(); if (!Service_Contact::update($contact, $data)) { Session::set_alert('error', 'There was an error updating the contact.'); return; } Session::set_alert('success', 'The contact has been updated.'); Response::redirect('settings/contacts'); }