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是列名稱.. –