dataRange() ->catchSearch() ->field('*') ->catchOrder() ->append(['type_name', 'depart_name']) ->creator() ->paginate(); } public function getWindList() { // 不分页 return $this->dataRange() ->catchSearch() ->field('*') ->catchOrder() ->append(['type_name', 'depart_name']) ->creator() ->select(); } /** * 获取风场类型(文本) */ public function getTypeNameAttr($value) { $type_arr = [ 'circle' => '圆形围栏', 'polygon' => '多边形围栏', ]; return $type_arr[$this->getData('wind_shape')] ?: '未知'; } public function getDepartmentIdAttr($value) { return json_decode($value, true); } public function getWindInfoAttr($value) { return json_decode($value, true); } public function getDepartNameAttr($value) { $id = $this->department_id; return Db::table('departments')->where('id', $id)->value('department_name'); } public function searchNameAttr($query, $value, $data) { return $query->where('name', 'like', '%' . $value . '%'); } //下发数据 public function addContent(&$obj) { //var_dump($obj); $data = null; $content = null; $jsonInfo = $obj->wind_info; $data = [ 'id' => $obj->id, 'number' => $obj->number, 'name' => $obj['name'], 'lon' => $jsonInfo['center']['lng'], 'lat' => $jsonInfo['center']['lat'] ]; $content['data'] = $data; $content['type'] = 'Wind'; return $content; } }