【发布时间】:2018-01-10 11:27:44
【问题描述】:
我目前有此代码,现在我需要一些帮助才能根据用户选择的内容使其正常工作。
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'?如果我直接输入会有如下错误:
类型错误:函数参数太少 App\Http\Controllers\xxxx\xxxx\xxxx::App\Http\Controllers\xxx\xxxx{closure}(), 1 个通过,恰好 2 个预期
【问题讨论】: