Last active
August 8, 2017 02:58
-
-
Save vutran0111/807637e8bf2659b06b6aaa4bf19d85ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function editService($id = null){ | |
if($this->request->is(array('post','put'))){ | |
$currentUser = $this->Auth->user(); | |
if($this->request->data['Service']['user_id'] != $currentUser['SppUser']['id']){ | |
$this->Session->setFlash(__('Bạn không có quyền chỉnh sửa thông tin của dịch vụ này.')); | |
return $this->redirect($this->referer()); | |
}else{ | |
if($this->Service->save($this->request->data)){ | |
$this->Session->setFlash(__('Đã cập nhật thành công.')); | |
return $this->redirect(array('action' => 'index')); | |
} else { | |
$this->Session->setFlash(__('Không lưu được thông tin. Vui lòng thực hiện lại.')); | |
} | |
} | |
} else { | |
if(!$this->Service->exists($id)){ | |
$this->Session->setFlash(__('Dịch vụ không tồn tại')); | |
return $this->redirect($this->referer()); | |
// throw new NotFoundException(__('Invalid service')); | |
} | |
$options = array('conditions' => array('Service.'. $this->Service->primaryKey => $id)); | |
$this->request->data = $this->Service->find('first', $options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment