【发布时间】:2021-12-29 04:45:53
【问题描述】:
在我的 Laravel 应用程序中,我创建了 url: like "www.example.com/rent/property-for-rent/45" 但在这里,我想从最后一个中删除 id 并将 id 与我的第二个参数连接起来,即“出租物业”,例如:“www.example.com/rent/property-for-rent-45”。
在Controller函数中获取3个参数
public function single_properties(Request $request, $property_purpose, $slug, $id)
在刀片文件中
{{url(strtolower($property->property_purpose).'/'.$property->property_slug)}}
在 Web.php 文件中
Route::get('{property_purpose}/{slug}/{id}', 'PropertiesController@single_properties');
我试图从函数、刀片和路由中减少参数,但对我不起作用。 谁能帮帮我,我被困在里面了,
【问题讨论】:
-
错误是什么?如果 slug 中包含一个 int 怎么办?