0
我目前有这个代码,现在我需要一些帮助,使其工作基于用户选择的内容。如何根据选定的值获取数据以获取excel?
public function downloadResponse(Request $request)
{
$inputs = $request->input();
$eType = $inputs['chapter_category'];
Excel::create('Export data', function($excel,$eType)
{
$excel->sheet('Sheet 1', function($sheet)
{
$products = Dialog::where('eType', 'claim_type')->get();;
foreach($products as $product)
{
$data[] = array(
$product->eType,
$product->eVal,
$product->intent,
$product->reply,
);
}
$sheet->fromArray($data, null, 'A1', false, false);
$headings = array('Entity Type', 'Entity Value', 'Intent', 'Reply');
$sheet->prependRow(1, $headings);
});
})->export('csv');
}
这一行我已经很难有线它:
$products = Dialog::where('eType', 'claim_type')->get();
那么,如何让$eType
,并与 'claim_type
' 更换呢?如果我把直会有错误象下面这样:
Type error: Too few arguments to function App\Http\Controllers\xxxx\xxxx\xxxx::App\Http\Controllers\xxx\xxxx{closure}(), 1 passed and exactly 2 expected
eType是列名称.. –