orderBy('listorder', 'asc')->get(); if($list) { foreach($list as $k=>$v) { $res[] = $v; $child = self::where(array('pid'=>$list[$k]->id,'is_show'=>self::IS_SHOW))->orderBy('listorder', 'asc')->get(); if($child) { foreach($child as $key=>$value) { $res[] = $value; } } } } else { return false; } return $res; } public static function getOne($where) { return self::where($where)->first(); } public static function add(array $data) { if ($id = self::insertGetId($data)) { return $id; } return false; } public static function modify($where, array $data) { if (self::where($where)->update($data) === false) { return false; } return true; } //删除一条记录 public static function remove($id) { if (!self::whereIn('id', explode(',', $id))->delete()) { return false; } return true; } //删除一条记录 public static function getWeixinMenuJson() { $where['pid'] = 0; $where['is_show'] = self::IS_SHOW; $list = self::where($where)->orderBy('listorder', 'asc')->get(); $res=''; if($list) { foreach($list as $k=>$v) { $child = self::where(array('pid'=>$list[$k]->id,'is_show'=>self::IS_SHOW))->orderBy('listorder', 'asc')->get(); if($child) { $temp_child=''; foreach($child as $key=>$value) { if($value->type == 'click') { $temp_child[] = array( 'type'=>$value->type, 'name'=>$value->name, 'key'=>$value->key ); } elseif($value->type == 'view') { $temp_child[] = array( 'type'=>$value->type, 'name'=>$value->name, 'url'=>$value->key ); } elseif($value->type == 'miniprogram') { $temp_child[] = array( 'type'=>$value->type, 'name'=>$value->name, 'url'=>$value->key, 'appid'=>$value->appid, 'pagepath'=>$value->pagepath ); } } $res[] = array( 'name'=>$value->name, 'sub_button'=>$temp_child ); } else { if($v->type == 'click') { $res[] = array( 'type'=>$v->type, 'name'=>$v->name, 'key'=>$v->key ); } elseif($v->type == 'view') { $res[] = array( 'type'=>$v->type, 'name'=>$v->name, 'url'=>$v->key ); } elseif($v->type == 'miniprogram') { $res[] = array( 'type'=>$v->type, 'name'=>$v->name, 'url'=>$v->key, 'appid'=>$v->appid, 'pagepath'=>$v->pagepath ); } } } } return json_encode($res); } }