Laravel 7.18.0 | 缺少 [路线:类别] 所需的参数

我的索引文件:


@foreach ($categories as $category)

                        <div class="panel panel-default">

                            <div class="panel-heading">

                                <h4 class="panel-title"><a href="{{ route('category', app()->getLocale(), $category->name) }}">{{ $category->name }}</a></h4>

                            </div>

                        </div>

@endforeach

我的路线文件:


Route::prefix('/{language}')->group(function () {

Route::get('/', ['uses' => 'IndexController@home', 'as' => 'home']);

Route::post('/', ['uses' => 'IndexController@price', 'as' => 'price']);


Route::get('contact', ['uses' => 'ContactController@show', 'as' => 'contact']);

Route::post('contact', ['uses' => 'ContactController@send', 'as' => 'contact-send']);


Route::get('/category/{category}', ['uses' => 'CategoryController@show', 'as' => 'category']); 

});


错误文本:缺少 [路线:类别] [URI:{语言}/类别/{类别}] 所需的参数。(查看:/Applications/MAMP/htdocs/shop/resources/views/index.blade.php)


我认为问题是我错误地插入了第二个参数,请帮助我,预先感谢;)


蝴蝶刀刀
浏览 107回答 1
1回答

开满天机

将参数作为数组传递。route('category',&nbsp;['language'&nbsp;=>&nbsp;app()->getLocale(),&nbsp;'category'&nbsp;=>&nbsp;$category->name])
打开App,查看更多内容
随时随地看视频慕课网APP