通过urlencode laravel返回404

时间:2017-10-18 07:57:37

标签: laravel-5

我尝试使用两个参数传递url,但得到错误404,bill_number包括/

这是我的路线

Route::prefix("monthly-bill")->group(function() {
Route::get("slip/{id}/{bill_number}", "MonthlyBillController@slip");
});

当我生成url时总是返回404

url("apt/monthly-bill/slip/".$billing->bill_period_id."/".rawurlencode($billing->bill_number))

这是我的控制器

public function slip($bill_period_id, $bill_number)
{
    $convert = new Convert(storage_path("tenant\config\document\slip.blade.php"));

    $convert->data([
        "title" => "Document",
        "date" => date("d F Y"),
        "items" => MonthlyBill::info()
                    ->billPeriod($bill_period_id)
                    ->billNumber($bill_number)
                    ->select("monthly_bill.*",
                        "bpr.*", "t.name", "t.unit_kind", "t.width")->first()
    ]);

    $file = $convert->to("pdf", "invoice-$bill_period_id.pdf", true);

    return response()->file($file);
}

1 个答案:

答案 0 :(得分:1)

我建议使用action()帮助

生成网址
action('MonthlyBillController@slip', [
    'id'          => $billing->bill_period_id,
    'bill_number' => $billing->bill_number,
])