mazuro
mazuro

Reputation: 32

Laravel 7.18.0 | Missing required parameters for [Route: category]

My index file:

@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

my route file:

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

});

error text: Missing required parameters for [Route: category] [URI: {language}/category/{category}]. (View: /Applications/MAMP/htdocs/shop/resources/views/index.blade.php)

I think the problem is that I am inserting the second argument incorrectly, please help me, thanks in advance;)

Upvotes: 1

Views: 63

Answers (1)

Aashish gaba
Aashish gaba

Reputation: 1776

Pass the parameters as an array.

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

Upvotes: 2

Related Questions