drfu29983 2015-12-09 01:29
浏览 52
已采纳

Laravel 5 href路线

any chance someone could explain to me how if for example I'm on http://localhost:8000/sales/create and I have a nav link that points to "sales/create" how I would go about structuring things so page is not directed to "sales/sales/create" when the link is clicked.

Apologies if the question is not clear.

Thank you in advance for any responses.

  • 写回答

1条回答 默认 最新

  • dougang6821 2015-12-09 01:46
    关注

    I prefer to just give a name to my route and then reference it with:

    <a href="{{ URL::route('sales/create' }}"> Create Sale </a>
    

    Then in your route, you would provide the name as an argument:

    Route::get('/sales/create', array(
        'name' => 'sales/create',
        'controller' => 'SalesController@create'
    ));
    

    If you would prefer not to do this, then just make sure that the path is absolute as opposed to relative.

    <a href="{{ URL::to('/sales/create') }}"> Create Sale </a>
    

    Note the leading / in front of sales.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程