【发布时间】:2019-02-03 00:22:23
【问题描述】:
我像这样插入网址:“export/1-2-18”。 1、2、18是表的id。 ID 由复选框选中,所以它可以是桌子上的任何数字
这样的href
<a href ="{{ url('export',['id'=> $a ]) }}" class="btn btn-info export" id="export-button"> Export file </a>
$a = 1-2-18;
这是控制器
public function exportFile($id){
$rp = str_replace('-',',',$id);
echo ($rp);
$products = DB::table('duan')
->whereIn('MaDA', [$rp])
->get();
dd($products);
$products= json_decode( json_encode($products), true);
return Excel::create('ThongTinDuAn', function($excel) use ($products) {
$excel->sheet('sheet name', function($sheet) use ($products)
{
$sheet->fromArray($products);
$sheet->getStyle('A2:E2')->getAlignment()->setWrapText(true);
});
})->export('xlsx');
}
我已将网址从“1-2-18”替换为“1,2,18”并插入到whereIn,但我只收到了其中一个结果。
如何获得所有结果?提前致谢。
【问题讨论】: