1 public function index(Request $request){
2 $list=DB::table("goods_order")->whereNotNull("accept_mobile")->get()->toArray();
3 $new=[];
4 foreach($list as $k=>$v){
5 $new[$v->accept_mobile]=$v->accept_name;
6 }
7 $data=[];
8 foreach($new as $kk=>$vv){
9 $data[]=[$vv,$kk];
10 }
11 $cellData[0] = array('姓名','手机号码');
12 for($i=1;$i<count($data);$i++){
13 $cellData[$i] = array_values($data[$i]);
14 }
15 Excel::create('用户信息',function($excel) use ($cellData){
16 $excel->sheet('score', function($sheet) use ($cellData){
17 $sheet->rows($cellData);
18 });
19 })->export('xls');
20 die;
21
22 }