Home > database >  Missing required parameter for [Route: cat] [URI: category/{category}] [Missing parameter: category]
Missing required parameter for [Route: cat] [URI: category/{category}] [Missing parameter: category]

Time:06-23

I am trying to send a static data to component and routes and not getting output.

This is my code -

Blade.php with using component -

<x-separator title="Hindi" titleURL="{{ route('cat',$category[0]) }}" />

Controller -

$category=['hindi','bengali','english','punjabi','tamil'];
return view('welcome',['category'=>$category]);

Routes -

Route::get('/category/{category}', [ZLController::class, 'cat'])->where('category', '[a-z-] ')->name('cat');

I tested below code in blade file -

<x-separator title="Hindi" titleURL="{{ dd(route('cat',$category[0])) }}" />

Output was - http://127.0.0.1:8000/category/hindi

And still getting this error Missing required parameter for [Route: cat] [URI: category/{category}] [Missing parameter: category].

CodePudding user response:

You are passing the data wrong. Try this

<x-separator title="Hindi" titleURL="{{ route('cat', ['category' => $category[0]]) }}" />

CodePudding user response:

Problem Solved by this way -

Route::get('/category/{category?}', [ZLController::class, 'cat'])->where('category', '[a-z-] ')->name('cat');
  • Related