Missing required parameters for [Route: listele] [URI: {language}/{slug}]

Missing required parameters for [Route: listele] [URI: {language}/{slug}] [Missing parameters: language, slug]. (View: C:xampphtdocsefsaneresourcesviewsproductproduct.blade.php)

What is the reason I am getting such an error?

Blade file

@foreach ($categories as $p)
    <a href="{{route('listele') , app()->getLocale(), $slug }}"class="list-group-item">{{$p->name}}</a>


 Route::group(['prefix' => '{language}'  ], function(){  

 Route::get('/{slug}' , 'AppHttpControllers<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d3d1f0209180e192e0203191f020101081f2d0e0c19080a021f14">[email protected]</a>')->name('listele');


My Controller

      public function category($slug)


     $category = Category::where('slug' , $slug )->first();
     $data['category'] = $category;

     $data['categories'] = Category::inRandomOrder()->get();

     $data['posts'] = Post::where('category_id' , $category->id)->orderBy('id',  'DESC')->paginate(10);
     return view('product.kategorilist' , $data );


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You will need to put the route paramter values in an array and put that array in your route method route('listele', [app()->getLocale(), $p->slug]).

You will also need to access the category slug from the object so you have to use $p->slug.

@foreach ($categories as $p)
 <a href="{{route('listele', [app()->getLocale(), $p->slug])}}"


There was also the </a> endtag missing


Your controller method defines only the $slug parameter. But you are defining a prefix in your route for the $language parameter and the route itself defines the $slug parameter.

You have to simply add another parameter called $language to your controller method.

      public function category($language, $slug) { .... }

In your case the language value was assigned to the slug variable and therefore no categroy was found (null is set). If you want to access an attribute of a null object you have a problem.

I would add a check to ensure $category is not null.

public function category($language, $slug) {

$category = Category::where('slug' , $slug )->first(); 
    return redirect()->back();

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x