public function updateOrDelete() { if (isset($_SESSION['client'])) { $client = unserialize($_SESSION['client']); if (isset($_POST['update'])) { $contactsModel = new ContactsModel(); $contact = $contactsModel->getBySelfURL($_POST['selfURL']); $contact->name = $_POST['name']; $contact->email = $_POST['mail']; $contactAfterUpdate = $contactsModel->submitUpdates($contact); } else { if (isset($_POST['delete'])) { $contactsModel = new ContactsModel(); $contact = $contactsModel->getBySelfURL($_POST['selfURL']); //var_dump($contact); //$contact->name = $_POST['name']; //$contact->email = $_POST['mail']; $contactAfterUpdate = $contactsModel->delete($contact); } } $this->helper->redirect('/contacts/getAll'); } else { $this->helper->redirect(); } }
public function DeleteAction() { $id = intval(Request::GetPart(3)); $contact = ContactsModel::GetObj()->where('id = ? AND company_id = ?', [0 => $id, 1 => $this->company->id]); if ($contact->id > 0) { ContactsModel::delete()->id($contact->id); } Site::Message('Контакт успешно удалён'); $this->route('profile'); }