0
0

SysArticle.php 693 B

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