【问题标题】:Laravel 7.18.0 | Missing required parameters for [Route: category]Laravel 7.18.0 | [Route: category] ​​缺少必需的参数
【发布时间】:2020-07-25 22:28:55
【问题描述】:

我的索引文件:

@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']); 

});

错误文本: [Route: category] ​​[URI: {language}/category/{category}] 缺少必需的参数。 (查看:/Applications/MAMP/htdocs/shop/resources/views/index.blade.php)

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

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    将参数作为数组传递。

    route('category', ['language' => app()->getLocale(), 'category' => $category->name])
    

    【讨论】:

      猜你喜欢
      • 2022-06-22
      • 2021-11-15
      • 2021-11-06
      • 2023-03-19
      • 1970-01-01
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多