【问题标题】:How the Url path from file path name to another name in laravel在 laravel 中如何从文件路径名到另一个名称的 Url 路径
【发布时间】:2018-04-13 07:16:01
【问题描述】:

在路线代码下方的鳍。

Route::get('clientlayout.main.index','InvoiceTicketController@show');
Route::get('clientlayout.main.mydomains','InvoiceTicketController@set');

当我运行这些路由时,我得到的 url 为

http://localhost:8000/clientlayout.main.indexhttp://localhost:8000/clientlayout.main.mydomains

我希望我的 Url 更改如下:http://localhost:8000/indexhttp://localhost:8000/mydomains

建议我更改路线以纠正此问题的解决方案。

【问题讨论】:

  • 使用 Route::get('/index','InvoiceTicketController@show');Route::get('/mydomains','InvoiceTicketController@set'); 代替您的路线

标签: laravel laravel-5 laravel-4 laravel-5.2 laravel-5.3


【解决方案1】:
Route::get('/index','InvoiceTicketController@show');
Route::get('/mydomains','InvoiceTicketController@set');

对于命名路由,您可以像这样使用

 Route::get('/index','InvoiceTicketController@show')->name('clientlayout.main.index');

更多详情请关注

https://laravel.com/docs/5.6/routing#named-routes

【讨论】:

    【解决方案2】:

    你应该试试这条路线。

    Route::get('/clientlayout/main/index','InvoiceTicketController@show');
    Route::get('/clientlayout/main/mydomains','InvoiceTicketController@set');
    

    网址正在制作中

    http://localhost:8000/clientlayout/main/index
    http://localhost:8000/clientlayout/main/mydomains
    

    或者你应该试试

    Route::get('/index','InvoiceTicketController@show');
    Route::get('/mydomains','InvoiceTicketController@set');
    

    那么Url正在制作

    http://localhost:8000/index
    http://localhost:8000/mydomains
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 2017-11-06
      • 2010-10-01
      • 1970-01-01
      • 2011-11-16
      • 1970-01-01
      相关资源
      最近更新 更多