我想让我的网站变得像localhost:8000/apartment/example-post-cat-come,而不是localhost:8000/example-post-cat-come
我有一些类别,如1.公寓2.公寓
我想在url中的弹格之前添加post类别。
目前我正在做这个
Route::get('/{post}','ShowPropertiesController@index')->name('posts.show');在尝试了第一条路线之后,我还做了以下操作
Route::get('{category}/{post}','ShowPropertiesController@index')->name('posts.show');在我的控制器里做了这个
public function index($category, $post)
{
// ...
}我有个错误,Missing required parameters for [Route: posts.show] [URI: {category}/{post}]. (View: C:\MAMP\htdocs\laravel-real-estate\resources\views\pages\welcome.blade.php),这是我的刀片
<a href="{{ route('posts.show',$properties->slug) }}">{{$properties->title}}</a>我怎样才能使类别显示在url之前?
发布于 2020-06-12 21:23:54
问题是在welcome.blade.php中,您应该传递所有必需的参数来路由:
<a href="{{ route('posts.show',['category' => CATEGORY, 'post' => POST]) }}">{{$properties->title}}</a>用值更改类别和发布
https://stackoverflow.com/questions/62352488
复制相似问题