MateCate.php 839 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class MateCate extends Base {
  5. public function updates(){
  6. $data = request()->post();
  7. $data['org_id'] =cur_org_id();
  8. $result = validate('MateCate')->check($data,[],'');
  9. if(true !== $result){
  10. $this->error = validate('MateCate')->getError();
  11. return false;
  12. }
  13. $id = $data['id'];
  14. unset($data['id']);
  15. if($id > 0){
  16. $data['update_time'] = date('Y-m-d H:i:s');
  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. }