123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\common\model;
- use think\Db;
- class MateGoods extends Base
- {
- protected $createTime = 'create_time';
- protected $updateTime = 'update_time';
- public $table = 'mate_goods';
- protected $validateName = 'MateGoods';
- public function updates(){
- $data = request()->post();
- $data['buy_time'] = $data['buy_time']?$data['buy_time']:null;
- $data['org_id'] = cur_org_id();
- $result = validate($this->validateName)->check($data,[],'');
- if(true !== $result){
- $this->error = validate($this->validateName)->getError();
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- if($id > 0){
- $data['update_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data,['id'=>$id]);
- }else{
- $data['create_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data);
- }
- if(!$ret){
- $this->error = '操作失败';
- return false;
- }
- return true;
- }
- public function getList($offset,$size,$where,$order){
- $list =$this
- ->where($where)
- ->limit($offset,$size)
- ->order($order)
- ->select()
- ->toArray();
- return $list;
- }
- }
|