【问题标题】:How to use slugs in routes如何在路由中使用 slug
【发布时间】:2020-12-03 22:31:57
【问题描述】:

有没有办法在我的路线中使用 slug,例如 domain/technicalInformation,它将是 domain/technical-information。谢谢!

PagesController.php

class PagesController extends Controller
{    
    public function technicalInformation(){
        return view('pages.technical-information');
    }
}

web.php

Route::get('/technicalInformation','ConsumerController@technicalInformation')->name('technical-information');

【问题讨论】:

  • 您可能需要向我们展示更多代码,technical-information 来自您的数据库吗?
  • 不,technicalInformation 是我的控制器中使用的功能。我读了一些关于蛞蝓的文档,它使用数据库吗?我现在不使用蛞蝓

标签: laravel routes slug


【解决方案1】:

你只要改成这个,它应该可以工作。

Route::get('/technical-information','ConsumerController@technicalInformation')->name('technical-information');

【讨论】:

  • 成功了!太感谢了!!我认为编辑该部分不会正确调用我的路线。
猜你喜欢
  • 1970-01-01
  • 2023-04-09
  • 2012-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-23
  • 2013-02-28
  • 1970-01-01
相关资源
最近更新 更多