2017-05-25 85 views
0

我使用laravel 5.0,我發送一個查詢字符串A標記與一個id。 我收到ID而不是查詢字符串數據Laravel 5.0:路由與查詢字符串

下面是代碼: 查看

<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4"> 
     <div class="img-decor"> 
      <a href="{{url('buycarddetail/'.$retailer->id)}}" class=""> 
       <img src="{{ assetnew('uploads/client_image/'.$retailer->image) }}" alt="..." class="img-rounded" width="200"> 
      </a> 
      <div class="deals-title"> 
      {{ $retailer->name }} 
       <div class="sub-details">Save up to {{ $retailer->discount }}%</div> 
      </div> 
     </div> 

    </div> 

控制器

public function buycarddetail($id = null, Request $request) 
    { 
     echo $id; 
      echo '<pre>'; $data = $request->all(); exit; 
     return view('buycarddetail'); 

    } 

路線

Route::get('buycarddetail/{id}', ['as' => 'buycarddetail', 'uses' => '[email protected]']); 

我想使用控制器 作進一步處理的查詢字符串數據基於

+0

從你的代碼很明顯,你只發送URL中沒有實際的查詢字符串數據的ID和鏈接。 '{{URL('buycarddetail /'.$ retailer-> ID)}}' – Sandeesh

+0

example.com/buycarddetail/17?_token=msUCIVKokmPg5yjq2vRzlOZbbuo2zeHIDzSYhQxI&_token=msUCIVKokmPg5yjq2vRzlOZbbuo2zeHIDzSYhQxI&brand=&buybrand=+&intialsearch=&price%5B%5D=0-25 – Tarzan

+0

@感謝Sandeesh,上面是URL。我如何發送查詢字符串並進入控制器 – Tarzan

回答

0

在你的代碼實際上並不附加任何查詢字符串生成的鏈接{{url('buycarddetail/'.$retailer->id)}}時,請幫忙。

根據您的意見,您可以使用查詢字符串生成指向您的路線的鏈接。

{{ route('buycarddetail', ['id' => $retailer->id, '_token' => csrf_token(), 'brand' => 'test', 'buybrand' => 'example']) }} 

這個例子會產生像

http://example.com/buycarddetail/17?_token=QHE8va7stXUOPabwTjKmXyJxdsuPSZ9VbH3uThwx&brand=test&buybrand=example