function destroy($params) { if (empty($params['id'])) { bail('Required parameter id not set.'); } $contact = new Contact($params['id']); $contact->destroy(); $this->redirectTo(array('controller' => 'Contact', 'action' => 'index')); }
public function set_destroy_post() { $ContactList = new ObjList(['db_where_Arr' => ['status' => -1], 'db_where_deletenull_Bln' => TRUE, 'model_name_Str' => 'Contact', 'limitstart_Num' => 0, 'limitcount_Num' => 100]); foreach ($ContactList->obj_Arr as $key => $value_contact) { $Contact = new Contact(['contactid_Num' => $value_contact->contactid_Num]); $Contact->destroy(); } if (!empty($ContactList->obj_Arr)) { $this->load->model('Message'); $this->Message->show(['message' => '銷毀成功', 'url' => 'admin/base/contact/set/set']); } else { $this->load->model('Message'); $this->Message->show(['message' => '已無可銷毀的項目', 'url' => 'admin/base/contact/set/set']); } }
public function destroy($id) { Contact::destroy($id); return Response::json(["status" => "OK"]); }
if ($checkEmail == 0) { if ($newContact->save()) { $newAddress = new Address(); $newAddress->contactId = $newContact->id; $newAddress->zipcode = $zipcode; $newAddress->address = $address; $newAddress->complement = $complement; $newAddress->neighborhood = $neighborhood; $newAddress->city = $city; $newAddress->state = $state; if ($newAddress->save()) { $data['msg'] = 'Contact saved successfully!'; $data['id'] = $newContact->id; } else { $data['msg'] = 'An error occurred while saving the contact!'; Contact::destroy($newContact->id); } } else { $data['msg'] = 'An error occurred while saving the contact!'; } } else { $data['msg'] = 'This email is already registered for a contact!'; } $contactList->response()->header('Content-Type', 'application/json'); echo json_encode($data); }); // Edit contact $contactList->put("/contacts/:id", function ($id) use($contactList) { $name = $contactList->request->params('name'); $email = $contactList->request->params('email'); $editContact = Contact::find($id);
/** * Remove the specified Contact from storage. * * @param int $id * @return Response */ public function destroy($id) { Contact::destroy($id); return Redirect::route('admin.contacts.index')->with('message', 'Data deleted successfully'); }
/** * Remove the specified resource from storage. * DELETE /admin\admincontact/{id} * * @param int $id * @return Response */ public function getDelete($id) { $delete = Contact::destroy($id); Session::flash('message', 'Contact has been deleted Successfully'); return Redirect::to('admin/contacts'); }