/** * Delete checked user * * @param \Illuminate\Support\MessageBag $error */ protected function actionDelete(&$error) { $action = $this->request()->post()->get('ACTION'); if ($action !== null) { if ($action['ACTION'] === 'delete') { if (isset($action['ID']) && is_array($action['ID'])) { $this->transaction()->begin(); Error::reset(); foreach ($action['ID'] as $id) { if ($id > 0) { if (!$this->delete($id)) { $this->transaction()->rollback(); $error = new MessageBag(['ID' => Error::get()]); return; } } } $this->transaction()->commit(); } $this->session()->setFlash($this->getFlashKey(), $this->trans('user.widgets.edit.delete_success')); $this->redirect($this->getCurPageParam([], ['post'])); } } }
/** * Update user * * @param integer $id * @return boolean */ public function update($id) { if ($this->isValid(false)) { if (!User::update($id, $this->getData())) { $error = Error::get(); if ($error instanceof ValidateException) { foreach ($error->all() as $key => $mess) { $this->fields[$key]->error[] = $mess; } } else { $mess = 'Message: ' . $error->getMessage() . '.Trace: ' . $error->getTraceAsString(); $this->log('user.form.edit')->err($mess); $this->addError($this->trans('user.form.edit.unknow_error')); } } else { return true; } } return false; }