我从这里获取教程:https://laravel-excel.maatwebsite.nl/docs/3.0/export/basics。
我的导出结果如下:
我想将id参数传递给导出文件。我尝试了这样做,但我没有获得id值。id的值为空。请问如何解决这个问题?
<?php
...
use App\Exports\ItemsDetailsExport;
class ItemController extends Controller
{
...
public function exportToExcel(ItemsDetailsExport $exporter, $id)
{
//dd($id); I get the result
return $exporter->download('Summary Detail.xlsx');
}
}
我的导出结果如下:
<?php
namespace App\Exports;
use App\Repositories\Backend\ItemDetailRepository;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\Exportable;
use Illuminate\Support\Facades\Input;
class ItemsDetailsExport implements FromCollection
{
use Exportable;
protected $itemDetailRepository;
public function __construct(ItemDetailRepository $itemDetailRepository)
{
$this->itemDetailRepository = $itemDetailRepository;
}
public function collection()
{
$test = Input::get('id');
dd('yeah', $test);
}
}
我想将id参数传递给导出文件。我尝试了这样做,但我没有获得id值。id的值为空。请问如何解决这个问题?