sassid = $sassid; } public function getData($page_id,$pageCount = 0,$sex=null) { $adver = (new AdvertModel()) ->where('page_id',$page_id) ->where('is_show',1) ->order("sort","desc") ->when(!empty($pageCount),function ($query) use($pageCount){ $query->limit(0,$pageCount); }) ->when(!empty($sex),function ($query) use($sex){ if($sex == 1) { $query->whereIn("sex","0,1"); } if($sex == 2) { $query->whereIn("sex","0,2"); } }) ->select() ->toArray(); $lData = []; foreach ($adver as $v) { $d['title'] = $v['title']; $d['text'] = $v['text']; $d['url'] = $v['url']; $d['img'] = $v['img']; $d['code'] = $v['code']; $tAr = []; $jsonData = empty($v['data']) ? [] : json_decode($v['data'],true); foreach($jsonData as $v2) { $tAr[$v2['code']] = [ 'name' => $v2['name'], 'type' => $v2['type'], 'value' => $v2[$v2['code']] ]; } // $d['data'] = $tAr; $lData[] = $d; } return $lData; } }