我想在url中传递两个参数。我的网址是http://localhost/buyforfund/fundraising/public/campaign_details/64
我想要这个网址:
http://localhost/buyforfund/fundraising/public/campaign_details/64/campaign_product_details/26
按钮点击我想要这个网址,我从路由名称给出按钮链接。但是会发生错误。
按钮链接:
<a href="{{ route('campaign_product_details.detail',$result->id) }}" class="hvr-float-shadow">View</a>
错误:
缺少[Route:campaign_product_details.detail] [URI:campaign_details / {campaign_id} / campaign_product_details / {product_id}]所需的参数。
我的路线:
Route::get('campaign_details/{campaign_id}/campaign_product_details',function(){
return view('/front/campaign_product_details');
});
Route::get('campaign_details/{campaign_id}/campaign_product_details/{product_id}','front\CampaignDetailsController@showCampaignProductDetails')->name('campaign_product_details.detail');
答案 0 :(得分:1)
尝试传递两个参数,如下所示:
Route::get('campaign_details/{campaign_id}/campaign_product_details/{product_id}', [
'as' => 'showCampaignProductDetails', 'uses' => 'CampaignDetailsController@showCampaignProductDetails']);
在您看来:
route('showCampaignProductDetails',['campaingn_id'=>$campaign_id,'product_id'=>$productId]);
答案 1 :(得分:0)
在你的标签中,第二个参数缺失
<a href="{{ url('campaign_details/$result->id/campaign_product_details/$product_id }}" title="Edit signature">
您也定义了第二个参数。
答案 2 :(得分:0)
同时传递产品ID
<a href="{{ route('campaign_product_details.detail',$result->id,$product->id) }}" class="hvr-float-shadow">View</a>