0
0

AppMgr.php 782 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class AppMgr extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. public function updates(){
  8. $data = request()->post();
  9. $result = validate('AppMgr')->check($data,[],'');
  10. if(true !== $result){
  11. $this->error = validate('AppMgr')->getError();
  12. return false;
  13. }
  14. $id = $data['id'];
  15. unset($data['id']);
  16. if($id > 0){
  17. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  18. }else{
  19. $data['create_time'] = date('Y-m-d H:i:s');
  20. $ret = $this->allowField(true)->save($data);
  21. }
  22. if(!$ret){
  23. $this->error = '操作失败';
  24. return false;
  25. }
  26. return true;
  27. }
  28. }