12345678910111213141516171819202122232425262728 |
- <?php
- namespace app\common\model;
- use think\Db;
- class SysArticle extends Base {
- public function updates(){
- $data = request()->post();
- $result = validate('SysArticle')->check($data,[],'');
- if(true !== $result){
- $this->error = validate('SysArticle')->getError();
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- if($id > 0){
- $ret = $this->allowField(true)->save($data,['id'=>$id]);
- }else{
- $ret = $this->allowField(true)->save($data);
- }
- if(!$ret){
- $this->error = '操作失败';
- return false;
- }
- return true;
- }
- }
|