Guest User

Untitled

a guest
Jun 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. public function actionUpdate($id) {
  2. $model = $this->findModel($id);
  3.  
  4. if ($model->load($_POST) && $model->save()) {
  5. return $this->redirect(['view', 'id' => $model->id]);
  6. } else {
  7. return $this->render('update', [
  8. 'model' => $model,
  9. ]);
  10. }
  11. }
  12.  
  13. public function beforeSave($insert) {
  14. if ($this->isAttributeChanged('name')) {
  15. rename($this->getOldAttribute('name') . '.pdf', $this->name . '.pdf');
  16. }
  17.  
  18. parent::beforeSave($insert);
  19. }
  20.  
  21. public function beforeSave() {
  22.  
  23. if ($this->isNewRecord) {
  24. $this->insertDate = new CDbExpression('NOW()');
  25. } else {
  26. $this->updateDate = new CDbExpression('NOW()');
  27. }
  28.  
  29. return parent::beforeSave();
  30. }
  31.  
  32. public function beforeSave() {
  33. $this->date = date('Y-m-d', $this->date);
  34. return parent::beforeSave();
  35. }
Add Comment
Please, Sign In to add comment