Beispiel #1
0
 /**
  * Updates a contact.
  *
  * @param Model_Contact $contact The contact to update.
  * @param array         $data    The data to use to update the contact.
  *
  * @return Model_Contact
  */
 public static function update(Model_Contact $contact, array $data = array())
 {
     $contact->populate($data);
     try {
         $contact->save();
     } catch (FuelException $e) {
         Log::error($e);
         return false;
     }
     return $contact;
 }
Beispiel #2
0
 /**
  * POST create action.
  * 
  * @return void
  */
 public function post_create()
 {
     $this->get_create();
     $contact = new Model_Contact();
     $contact->populate(Input::post());
     $validator = Validation_Contact::create('seller');
     if (!$validator->run()) {
         Session::set_alert('error', __('form.error'));
         $this->view->errors = $validator->error();
         return;
     }
     $data = $validator->validated();
     $data['first_name'] = '';
     $data['last_name'] = '';
     if (!($new_contact = Service_Contact::create($data))) {
         Session::set_alert('error', 'There was an error creating the contact.');
         return;
     }
     Service_Contact::link($new_contact, Seller::active());
     Session::set_alert('success', 'The contact has been created.');
     Response::redirect('settings/contacts');
 }