123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\common\model;
- use think\Db;
- class WxGoodsCate extends Base
- {
- public function updates(){
- $data = request()->post();
- $data['org_id'] = cur_org_id();
- $result = validate('WxGoodsCate')->check($data,[],'');
- if(true !== $result){
- $this->error = validate('WxGoodsCate')->getError();
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- if($id > 0){
- $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 lists($orgId){
- $ret=Db::name('wx_goods_cate')
- ->field('id,title,is_water,path')
- ->where(['org_id'=>$orgId,'enable'=>1,'del'=>0])
- ->order(['sort'=>'asc','id'=>'desc'])
- ->select();
- // $data=[
- // [
- // 'id'=>0,
- // 'title'=>'全部'
- // ],
- // ];
- // foreach ($ret as $k=>$v){
- // $data[] = $v;
- // }
- return $ret;
- }
- public function getLabel(){
- $ret=Db::name('wx_goods_label')
- ->where('enable',1)
- ->where('del',0)
- ->select();
- return $ret;
- }
- }
|