Laravel 使用参数路由资源丰富的控制器

Laravel Routing a resourceful controller with parameter

我一直在使用 Resourceful 控制器,因为它很简单。像这样。

route('branches.create')

但我目前的业务需要需要我传递一个特定的参数。

current/{company}/branches

我怎样才能创建适合这种 url 的路线。我试过 route('current.branches.create') 和 route('current.' . $id . 'branches.create')

保持路线为 named routes 如:

Route::POST('current/{company}/branches', 'SomeController@somemethod')->name('branches.create');

并通过 URL 如:

<a href="{{route('branches.create', $company->id)}}">GOT TO URL</a>

更多关于Larvel Named Routes

希望对您有所帮助。