dtn51137 2017-10-26 08:14
浏览 126
已采纳

在laravel中获取URL参数

In my route I have like this

Route::get('/library/{id?}', 'LibraryController@index')->name('library');

and returning my url to http://localhost/dmb/library/2017

In my blade how can I check and display if I have that 2017 in my url?

  • 写回答

1条回答 默认 最新

  • douduikai0562 2017-10-26 08:20
    关注

    this code will help you

    if you want to get library then you should used

    $segment = Request::segment(1);
    

    for 2017 then used segment(2)

    $segment = Request::segment(2);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?