Php 单击“导出excel”按钮时如何传递链接参数?

Php 单击“导出excel”按钮时如何传递链接参数?,php,laravel,Php,Laravel,我需要帮助在URL上传递参数 routes.php blade.php 在blade.php中,尝试将第二个参数设置为带有type属性和要传递的值的数组 如果是“xls”,则应为以下内容: <a href="{{ URL::to('/downloadExcel', array("type" => "xls")) }}"></a> 您是否将类型声明为变量?@kusy yes..请参阅我的控制器:)我想更改href上的url。您的代码有什么问题?它应该work@He

我需要帮助在URL上传递参数

routes.php blade.php
在blade.php中,尝试将第二个参数设置为带有
type
属性和要传递的值的数组

如果是“xls”,则应为以下内容:

<a href="{{ URL::to('/downloadExcel', array("type" => "xls")) }}"></a>


您是否将类型声明为变量?@kusy yes..请参阅我的控制器:)我想更改href上的url。您的代码有什么问题?它应该work@Hemelraj我想在单击“导出到excel”时传递url,先生。href=“{URL::to('/downloadExcel/xls')}}”您可以将控制器粘贴到调用该视图的位置吗?不是这样。但问题是关于链接中的参数。缺少数据,因为$transaksi变量没有值。在return语句之前为其分配数据。数据已经存在,先生..我只需要在URL上传递链接。好的,先生,我现在有解决办法了。
<a href="{{ URL::to('/downloadExcel/xls') }}" class="btn btn-warning btn-sm hidden-print"><i class="glyphicon glyphicon-export"></i> Export to Excel</a>
class ExcelController extends Controller{
    public function downloadExcel($type, Request $request)
    {
     return Excel::create('Laporan Kehadiran Harian', function($excel) use 
      ($transaksi) {
            $excel->sheet('mySheet', function($sheet) use ($transaksi)
            {
                $sheet->fromArray($transaksi);
            });
        })->download($type);
    }
}
<a href="{{ URL::to('/downloadExcel', array("type" => "xls")) }}"></a>