如何在laravel中的url中传递三个变量

时间:2017-06-23 06:32:58

标签: laravel-5

路由::获取('报告/ {报告} /离开',[' as' =>' reports.leave','使用' =>' ReportController @ leave']);

@foreach($ dat as $ report)

    <?php 
         $date=$_POST['date']; 
         $fdate=$_POST['fdate'];
          ?>
        <td><a href="{{ URL::route('admin.reports.leave',$report->name,$fdate) }}">{!!$report->name!!}</td>

2 个答案:

答案 0 :(得分:0)

要传递三个变量,您可以尝试以下示例代码:

路线:

Route::get('admin/{variable_1}/reports/{variable_2}/leave/{variable_3}', 'ReportController@leave');

控制器方法:

public function leave($variable_1, $variable_2, $variable_3){

}

HTML(刀片)链接:

<a href="{{ url('admin/'.$variable_1.'/reports/'.$variable_2.'/leave/'.$variable_3) }}">{!!$report->name!!}</a>

答案 1 :(得分:0)

尝试下面给出的代码:
<强>路线

Route::get('reports/{reports}/leave/{date}/{fdate}', [
'as'=> 'reportsLeave', 'uses' =>'ReportController@leave']);

<强>刀片

@foreach($dat as $report)
<?php 
    $date=$_POST['date']; 
    $fdate=$_POST['fdate'];
    ?><td><a href="{{ URL::route('reportsLeave',[$reports => $report->name, 'date' => $date, 'fdate' => $fdate) }}">{!!$report->name!!}</td>

<强>控制器

public function leave($reports, $date, $fdate){...}

希望以上建议的方式对你有用。运气最好!