1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\common\model;
- use think\Db;
- class HouseFee extends Base
- {
- protected $createTime = 'create_time';
- protected $updateTime = 'update_time';
- public $table = 'house_fee';
- protected $validateName = 'HouseFee';
- public function updates(){
- $data = request()->post();
- $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 getTree($orgId){
- $list = $this
- ->where('parent_id',0)
- ->where('del',0)
- ->where('org_id',$orgId)
- ->order('sort','asc')
- ->select()
- ->toArray();
- foreach ($list as $k=>$v){
- $list[$k]['depth'] = 0;
- $two =$this
- ->where('parent_id',$v['id'])
- ->where('del',0)
- ->where('org_id',$orgId)
- ->order('sort','asc')
- ->select()
- ->toArray();
- foreach ($two as $l=>$t){
- $two[$l]['depth'] = 1;
- }
- $list[$k]['child'] =$two;
- }
- return $list;
- }
- }
|